If you have specific requirements in how to identify exceptions and how to structure your error and exception codes, you have to customize the de.smartics.exceptions.ExceptionContext.
This context provides all customizable information.
The customization options are for application development only. Libraries must not provide exception context information in their artifacts.
The basic element of the configuration is the the factory for creating exception identifiers.
public interface ExceptionContext { /** * Returns the configuration to control the handling of throwables. * * @return the configured mode. */ ThrowableHandleMode getThrowableHandleMode(); /** * Returns the factory for generating identifiers. * * @return the factory for generating identifiers. */ IdFactory getIdFactory(); /** * Returns the formatter for code messages. Override to control the * representation of exception and message bean instances. * * @return the formatter for code messages. */ CodeMessageFormatter getCodeMessageFormatter(); }
To provide a custom implementations for exception context you may consider to extend de.smartics.exceptions.context.AbstractExceptionContext.
To provide a custom implementations for exception identifiers you have to provide an de.smartics.exceptions.core.IdFactory and configure it with your ExceptionContext implementation.
Note: The exception identifier identifies the exception instance, wile the exception code identifies the type of the problem. The type of the problem is not necessarily the same as the type of the exception, since you may have different problems that map to the same exception type.
To provide a custom implementations to format exceptions to their string representations, implement de.smartics.exceptions.core.CodeMessageFormatter and configure it with your ExceptionContext implementation.
The default formatting is implemented by de.smartics.exceptions.core.DefaultCodeMessageFormatter.
Please note that the I18N module requires a more sophisticated interface to its messages and exceptions. For details please refer to Customize for I18N.