When invoking server operations the call may not go as expected (a result is returned). If that happens an exception is thrown to indicate there is a problem. Exceptions can be thrown for a number of reasons such as server is down, wrong username/password, malformed input etc.
The exception type thrown is the APException. A few
methods can throw other types of exceptions; FndException
and
IOException
can be thrown when changing Records to other formats (Buffer
or to/from file). IllegalStateException
can be thrown if you try to
get an attribute value from a record as the wrong type. But these other
exceptions are not thrown by the Server's invoke()-method.
The APException class holds information on what went wrong with the server call. It has a message, like all Java exceptions, but it also have an error type, sub-type and possibly a root cause exception object.
The error type of an APException is determined by comparing the result of the
getErrorType()
method to any of the fields in the ErrorType
class. Example:
if(ex.getErrorType() == ErrorType.APPLICATION_EX){
These are the error types:
Error Type | Description |
---|---|
APPLICATION_EX | Application errors from the server. Example: the input is missing some required data. |
BAD_CREDENTIALS | The user credentials (username & password) are not valid or are not set at all. |
COMM_EX | Failure in client-server communication. Example: the server is down. |
DATABASE_EX | Database related error from the server. When this occurs, exceptions of type DatabaseException is thrown. |
EXCEPTION_EX | Other types of errors on the application server. Example: malformed input buffer to the server. |
FND_EX | Originally an FndException which is wrapped in the APException. This type of errors have their origin from the buffer handling Java classes. |
IO_EX | Originally an IOException which is wrapped in the APException. |
SECURITY_EX | Security errors. Example: the user may not be authorized to run the operation requested. |
UNKNOWN_EX | All other type of errors. Always a client-side excpetion. |
VALIDATION_EX | This is a special type of exception. This is thrown when some data validation fails, for instance of some required data is missing. When this occurs, exceptions of type ValidationException is thrown. |
The APPLICATION_EX, BAD_CREDENTIALS, DATABASE_EX, EXCEPTION_EX, SECURITY_EX and VALIDATION_EX types of errors always have their origin in the server.
For COMM_EX, FND_EX, IO_EX and UNKNOWN_EX are all client side exceptions. That is, their origin is a Java exception thrown somewhere in the code. That exception is available via the getRootCause() method in APException class.