SOURCECODE |
How to... define new error code
Description:
There are several predefined error codes in class SaleProcess.
Any user defined error code must be outside interval [ERR_LOWERBOUND, ERR_UPPERBOUND].
Predefined:
DATABASKET_CONFLICT_ERROR, DUPLICATE_KEY_EXCEPTION, ERR_INTERNAL, ERR_NOERROR, NOT_ENOUGH_ELEMENTS_ERROR, REMOVE_VETO_EXCEPTION
ToDo's:
- Select SaleProcess where you want to add own error codes
- Add global attributes of new error codes.
They have to be lower than ERR_LOWERBOUND or higher than ERR_UPPERBOUND.
- Implement
public String getErrorMsg(int nErrorCode)
method to enable user defined error codes.
Call super.getErrorMsg(int nErrorCode)
method to enable predefined error codes.
Uses:
SaleProcess ProcessErrorCodes
1
// Main Class
public class RentProcess extends SaleProcess
{
2
// Code of user defined error
// (must lower than ERR_LOWERBOUND or higher than ERR_UPPERBOUND)
public static final int ERR_MY_NEW_ERROR = ERR_LOWERBOUND -1;
3
// Method has to be overwritten, but donīt forget to call method of superclass
public String getErrorMsg(int nErrorCode)
{
switch (nErrorCode)
{
case ERR_MY_NEW_ERROR:
return "My new error occured. ";
default:
return super.getErrorMsg(nErrorCode);
}
}
}