Local and Dispatch Exceptions

2 min read

2 min read

2 min read

2 min read

2 min read

2 min read

2 min read

2 min read

2 min read

The Ice runtime reports errors by throwing local exceptions, which derive from LocalExceptionLocalExceptionLocalExceptionLocalExceptionLocalExceptionLocalExceptionLocalExceptionLocalExceptionLocalException: for example, when it cannot establish a connection or when an invocation times out. Some Ice APIs also throw standard exceptions, such as std::invalid_argument in C++ or IllegalArgumentException in Java.

The exceptions you define in Slice are user exceptions. A user exception is an error result of an operation, which you receive only from a twoway invocation. In every language mapping, the class mapped from a Slice exception derives from UserExceptionUserExceptionUserExceptionUserExceptionUserExceptionUserExceptionUserExceptionUserExceptionUserException.

A dispatch exception is a local exception that reports the failure of the dispatch of a twoway request, such as a request for an Ice object that the object adapter does not host. The object adapter reports this failure with the reply status of its reply message, and Ice throws the corresponding dispatch exception in the caller.

Dispatch exceptions derive from DispatchExceptionDispatchExceptionDispatchExceptionDispatchExceptionDispatchExceptionDispatchExceptionDispatchExceptionDispatchExceptionDispatchException, whose replyStatus field holds the reply status. For the reply statuses ObjectNotExist through UnknownException, Ice throws the exception class named after the reply status; for the other reply statuses, such as InvalidData, Unauthorized, and NotSupported, it throws a DispatchException.

ObjectNotExistExceptionObjectNotExistExceptionObjectNotExistExceptionObjectNotExistExceptionObjectNotExistExceptionObjectNotExistExceptionObjectNotExistExceptionObjectNotExistExceptionObjectNotExistException, FacetNotExistExceptionFacetNotExistExceptionFacetNotExistExceptionFacetNotExistExceptionFacetNotExistExceptionFacetNotExistExceptionFacetNotExistExceptionFacetNotExistExceptionFacetNotExistException, and OperationNotExistExceptionOperationNotExistExceptionOperationNotExistExceptionOperationNotExistExceptionOperationNotExistExceptionOperationNotExistExceptionOperationNotExistExceptionOperationNotExistExceptionOperationNotExistException derive from RequestFailedExceptionRequestFailedExceptionRequestFailedExceptionRequestFailedExceptionRequestFailedExceptionRequestFailedExceptionRequestFailedExceptionRequestFailedExceptionRequestFailedException, which carries the identity, facet, and operation of the request. UnknownLocalExceptionUnknownLocalExceptionUnknownLocalExceptionUnknownLocalExceptionUnknownLocalExceptionUnknownLocalExceptionUnknownLocalExceptionUnknownLocalExceptionUnknownLocalException and UnknownUserExceptionUnknownUserExceptionUnknownUserExceptionUnknownUserExceptionUnknownUserExceptionUnknownUserExceptionUnknownUserExceptionUnknownUserExceptionUnknownUserException derive from UnknownExceptionUnknownExceptionUnknownExceptionUnknownExceptionUnknownExceptionUnknownExceptionUnknownExceptionUnknownExceptionUnknownException.

A servant can throw a dispatch exception, which the caller receives. When a servant throws another local exception, the caller receives an UnknownLocalException, and for an exception that is neither a local exception nor a user exception, an UnknownException. Ice throws UnknownUserException locally, in the caller, when a reply carries a user exception that is not in the exception specification of the operation.