Class ProblemAdapters
java.lang.Object
org.apache.juneau.bean.rfc7807.adapter.ProblemAdapters
Static adapters that convert Juneau HTTP error types into
RFC 7807
Problem beans.
This adapter lives in juneau-rest-common (rather than the juneau-bean-rfc7807 bean module) so the
bean module stays free of any juneau-rest-common dependency. The package is co-located with the bean's
package namespace so the cross-reference is discoverable from Problem's javadoc.
Example:
Notes:
typeis intentionally leftnull. RFC 7807 §3.1 definesabout:blankas the default when the field is absent; the bean serializes anulltypeas an omitted field rather than as"type":"about:blank"on the wire (preserves the absent-vs-explicit distinction).detailis suppressed when the exception's message exactly matches the reason phrase — the bare case where the message would just echonew NotFound()"Not Found".
See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProblemBuilds aProblemfrom aBasicHttpException(or any subclass likeNotFound,InternalServerError, etc).
-
Method Details
-
fromException
Builds aProblemfrom aBasicHttpException(or any subclass likeNotFound,InternalServerError, etc).Mapping:
status←BasicHttpException.getStatusCode()title←HttpStatusLine.getReasonPhrase()(may benull)detail←BasicHttpException.getMessage(), but only when it differs from the reason phrase; otherwisenullso the bare case omits a redundantnew NotFound()"detail":"Not Found"field.type,instance← never set by this adapter (callers add them via the fluent setters on the returned bean if atypeURI is appropriate).
- Parameters:
e- The exception to adapt. May benull .- Returns:
- A new
Problempopulated from the exception, ornull ifeisnull .
-