# Package org.apache.olingo.odata2.api.exception

Exception Classes used in the OData library as well as the implementing application APPLICATION DEVELOPERS: Please use `ODataApplicationException` for custom exceptions.

See: Description

- Class Summary
  Class | Description
  --- | ---
  MessageReference | APPLICATION DEVELOPERS: Please use `ODataApplicationException` to throw custom exceptions.

- Exception Summary
  Exception | Description
  --- | ---
  ODataApplicationException | This class represents a translated application exception.
  ODataBadRequestException | Exceptions of this class will result in a HTTP status 400 bad request
  ODataConflictException | Exceptions of this class will result in a HTTP status 409 Conflict
  ODataException | Base exception for all `OData`-related exceptions.
  ODataForbiddenException | Exceptions of this class will result in a HTTP status 403 forbidden
  ODataHttpException | `ODataMessageException` with a HTTP status code.
  ODataInternalServerErrorException |
  ODataMessageException | DO NOT EXTEND THIS EXCEPTION APPLICATION DEVELOPERS: please use `ODataApplicationException` o throw custom exceptions.
  ODataMethodNotAllowedException | Exceptions of this class will result in a HTTP status 405 (method not allowed).
  ODataNotAcceptableException | Exceptions of this class will result in a HTTP status 406 not acceptable
  ODataNotFoundException | Exceptions of this class will result in a HTTP status 404 not found
  ODataNotImplementedException | Exceptions of this class will result in a HTTP status 501 (Not implemented).
  ODataPreconditionFailedException | Exceptions of this class will result in a HTTP Status 412 Precondition Failed.
  ODataPreconditionRequiredException | Exceptions of this class will result in a HTTP status 428 precondition required
  ODataRuntimeApplicationException | This class represents a translated application runtime exception.
  ODataServiceUnavailableException | Exceptions of this class will result in a HTTP status 503 service unavailable
  ODataUnsupportedMediaTypeException | Exceptions of this class will result in a HTTP status 415 unsupported media type

## Package org.apache.olingo.odata2.api.exception Description

Exception Classes used in the OData library as well as the implementing application

APPLICATION DEVELOPERS: Please use `ODataApplicationException` for custom exceptions.

Exception handling:
Inside the OData library an ExceptionMapper exists which can transform any exception into an OData error format. The ExceptionMapper behaves after the following algorithm:
1. The cause of the exception will be determined by looking into the stack trace.
1.1. If the cause is an ODataApplicationException meaning that somewhere in the stack an ODataApplicationException is found the ExceptionMapper will take the following information from the ApplicationException and transform it into an OData error: message text, Locale, Inner Error and Error Code. There will be no altering of information for the ODataApplicationException.
1.2. If no ODataApplicationException is found in the stack the cause can be three different types of exceptions: ODataHttpException, ODataMessageException or an uncaught RuntimeException.
The ExceptionMapper will process them in the following order: 1. ODataHttpException, 2. ODataMessageException, 3 Other Exceptions.
1.2.1. ODataHttpExceptions will be transformed as follows: If an error code is set it will be displayed. The HTTP status code will be derived from the ODataHttpException. The message text and its language depend on the AcceptLanguageHeaders. The first supported language which is found in the Headers will result in the language of the message and the response.
1.2.1. ODataMessageException will be transformed as follows: If an error code is set it will be displayed. The HTTP status code will be 500. The message text and its language depend on the AcceptLanguageHeaders. The first supported language which is found in the Headers will result in the language of the message and the response.
1.2.1 Runtime Exceptions will be transformed as follows: No error code will be set. HTTP status will be 500. Message text will be taken from the exception and the language for the response will be English as default.

Exception Hierarchy
`ODataException`
* `ODataApplicationException`
* `ODataMessageException`
** `EdmException`
** `EntityProviderException`
** `ExceptionVisitExpression`
** `ODataHttpException`
*** `ODataConflictException`
*** `ODataForbiddenException`
*** `ODataMethodNotAllowedException`
*** `ODataNotAcceptableException`
*** `ODataNotImplementedException`
*** `ODataPreconditionFailedException`
*** `ODataPreconditionRequiredException`
*** `ODataServiceUnavailableException`
*** `ODataUnsupportedMediaTypeException`
*** `ODataNotFoundException`
**** `UriNotMatchingException`
*** `ODataBadRequestException`
**** `ExpressionParserException`
**** `UriSyntaxException`

Copyright © 2013-2023 The Apache Software Foundation. All Rights Reserved.