Class ProblemAdapters

java.lang.Object
org.apache.juneau.bean.rfc7807.adapter.ProblemAdapters

public final class ProblemAdapters extends Object
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:

try { ... } catch (NotFound e) { Problem p = ProblemAdapters.fromException(e); // p.getStatus() == 404, p.getTitle() == "Not Found", p.getDetail() == e.getMessage() }

Notes:
  • type is intentionally left null. RFC 7807 §3.1 defines about:blank as the default when the field is absent; the bean serializes a null type as an omitted field rather than as "type":"about:blank" on the wire (preserves the absent-vs-explicit distinction).
  • detail is suppressed when the exception's message exactly matches the reason phrase — the bare new NotFound() case where the message would just echo "Not Found".
See Also: