Class ErrorCode
java.lang.Object
com.saperion.common.lang.exception.ErrorCode
- All Implemented Interfaces:
Serializable
Base class of all error codes for BaseException
s.
The error code consists of an obligatory "product" an optional "module" and an obligatory "number". Product and module should be short or abbreviations and should follow a pattern standardized by conventions.
In its written form (see getString()
) the parts will be converted to upper case, combined and separated by
an "-"-character, f.e. "JCR-4711" or "ECM-TPS-42".
toString()
creates a string for debugging and protocol purpose and should not be used for business
semantics.
It is recommended for all products to create their own product-specific extension of ErrorCode
encapsulating
the product-name-part of the error code, f.e.:
public class MyProductErrorCode extends ErrorCode { private static final String PRODUCT = "JCS"; public MyProductErrorCode(String module, int number) { super(PRODUCT, module, number); } public MyProductErrorCode(int number) { super(PRODUCT, number); } }A product can also enforce the use (or no use) of the module part by omitting one of the constructors in its own error code extension.
- Author:
- agz
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
SERARATOR
The separator to use when formatting the written form.- See Also:
-
-
Constructor Details
-
ErrorCode
Creates a newErrorCode
with the specified product, module and number. The specified product must not benull
or empty. The specified module is optional (may benull
). The specified number must be greater than0
.- Parameters:
product
- product of the new error codemodule
- module of the new error codenumber
- number of the new error code
-
ErrorCode
Creates a newErrorCode
with the specified product, module and number. The specified product must not benull
or empty. The specified number must be greater than0
.- Parameters:
product
- product of the new error codenumber
- number of the new error code
-
-
Method Details
-
getProduct
Returns the product (upper case).- Returns:
- the product
-
getModule
Returns the module (upper case) ornull
if no module was specified.- Returns:
- the module
-
getNumber
public final int getNumber()Returns the number.- Returns:
- the number
-
getString
Returns the written form of this error code. It is a combination of the product, module and number part, separated by a "-"-character, f.e. "JCR-4711" or "ECM-TPS-42" If used in aBaseException
, this written form is the resource key used for localization.- Returns:
- the written form of this error code.
-
toString
-