@CompileStatic class DomainException extends RuntimeException
Intended to communicate non-fatal domain conditions that prevent successful fulfillment of the requested operation.
Domain violation conditions are expressed via contained ViolationInfo structure. By default (meaning, when using simpler constructors), stack-trace is not created. The primary reason is thatDomainException
, and all its subclasses, are used as alternative response
value from the domain. They should represent benign violations like validation errors or not-found scenarios for queries. Serious error or fatal conditions should not be communicated via
DomainException
hierarchy.
In addition, the lack of stack-trace is also beneficial for technical reasons since our domain implementations (aggregates and query handlers) are communicating remotely with domain facade
services at the domain boundary. However, there should be means (and there are) to produce relevant stack traces, at least for development. Implementation of such development-time helpers can be
examined in CommandHandlerExceptionInterceptor
and QueryHandlerExceptionInterceptor
classes. Type | Name and description |
---|---|
String |
message |
ViolationInfo |
violationInfo Data structure describing the reason for the exception. |
Constructor and description |
---|
DomainException() |
DomainException(ViolationInfo violationInfo) |
DomainException(ViolationInfo violationInfo, String message) |
DomainException(ViolationInfo violationInfo, String message, Boolean writableStackTrace) |
DomainException(ViolationInfo violationInfo, String message, Throwable cause, Boolean writableStackTrace) |
Methods inherited from class | Name |
---|---|
class RuntimeException |
printStackTrace, printStackTrace, printStackTrace, getStackTrace, fillInStackTrace, getCause, initCause, toString, getMessage, getSuppressed, getLocalizedMessage, setStackTrace, addSuppressed, equals, hashCode, getClass, notify, notifyAll, wait, wait, wait |
Data structure describing the reason for the exception.
Groovy Documentation