Interface ErrorResolver
- All Known Implementing Classes:
FallbackErrorResolver
,WebClientBadRequestExceptionErrorResolver
,WebClientExceptionErrorResolver
public interface ErrorResolver
Implementations handle mapping specific exceptions to readable error messages. Implementation
notes:
- The
Throwable
supplied is always the most derived throwable, so the implementation does not need to traverse the exception hierarchy. - Only the first error resolver that returns true from
canResolve(Throwable)
will handle an error. To ensure that custom implementations are first, consider using theOrder
annotation. - Framework implementations are ordered with
Ordered.LOWEST_PRECEDENCE
or close to lowest precedence so that they may be easily superseded by custom implementations, though they may also be extended and overridden just like any Broadleaf component.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if this resolver can map the exception to a readable error message.resolve
(DataExchangeError error, Throwable t) Maps the exception to a readable error message.
-
Method Details
-
canResolve
Returns true if this resolver can map the exception to a readable error message.- Parameters:
t
- the exception- Returns:
- true if this resolver can map the exception to a readable error message
-
resolve
Maps the exception to a readable error message. The supplied error object will be initialized withDataExchangeError.getPath()
populated. Implementations should handle populating any additional information that will be returned.It is possible for implementations to return a different error object than the one supplied. If this is needed, the returned error object should have the same path as the supplied error object.
- Parameters:
error
- The error object to populate.t
- the exception- Returns:
- a readable error message
-