org.apache.olingo.odata2.api.exception

## Class ODataMessageException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - org.apache.olingo.odata2.api.exception.ODataException
      - - org.apache.olingo.odata2.api.exception.ODataMessageException

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    BatchException, EdmException, EntityProviderException, ExceptionVisitExpression, ODataHttpException

      public abstract class ODataMessageException
      extends ODataException

  DO NOT EXTEND THIS EXCEPTION

  APPLICATION DEVELOPERS: please use `ODataApplicationException` o throw custom exceptions.

  Base exception class for all exceptions in the `OData` library. This class extends `ODataException` with a message that will be displayed to a possible client and therefore needs support for internationalization.
  To support internationalization and translation of messages, this class and its sub classes contain a `MessageReference` object which can be mapped to a related key and message text in the resource bundles.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static MessageReference` | `COMMON` Reference to common message for a `ODataMessageException`
    `protected String` | `errorCode` OData error code
    `protected MessageReference` | `messageReference` Message reference for exception which is used for internationalization

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ODataMessageException(MessageReference messageReference)` Creates `ODataMessageException` with given `MessageReference`.
    `ODataMessageException(MessageReference messageReference, String errorCode)` Creates `ODataMessageException` with given `MessageReference` and error code.
    `ODataMessageException(MessageReference messageReference, Throwable cause)` Creates `ODataMessageException` with given `MessageReference` and cause `Throwable` which caused this exception.
    `ODataMessageException(MessageReference messageReference, Throwable cause, String errorCode)` Creates `ODataMessageException` with given `MessageReference`, cause `Throwable` and error code.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static MessageReference` | `createMessageReference(Class<? extends ODataMessageException> clazz, String messageReferenceKey)` Creates `MessageReference` objects more conveniently.
    `String` | `getErrorCode()` Gets the error code for this `ODataMessageException`.
    `String` | `getMessage()`
    `MessageReference` | `getMessageReference()` Gets the related `MessageReference`.

    - ### Methods inherited from class org.apache.olingo.odata2.api.exception.ODataException

      `getApplicationExceptionCause, getHttpExceptionCause, getMessageExceptionCause, isCausedByApplicationException, isCausedByHttpException, isCausedByMessageException`

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### messageReference

          protected final MessageReference messageReference

      Message reference for exception which is used for internationalization

    - #### errorCode

          protected final String errorCode

      OData error code

    - #### COMMON

          public static final MessageReference COMMON

      Reference to common message for a `ODataMessageException`

  - ### Constructor Detail

    - #### ODataMessageException

          public ODataMessageException(MessageReference messageReference)

      Creates `ODataMessageException` with given `MessageReference`.
      Parameters:
        `messageReference` - references the message text (and additional values) of this `ODataMessageException`

    - #### ODataMessageException

          public ODataMessageException(MessageReference messageReference,
                                       Throwable cause)

      Creates `ODataMessageException` with given `MessageReference` and cause `Throwable` which caused this exception.
      Parameters:
        `messageReference` - references the message text (and additional values) of this `ODataMessageException`
        `cause` - exception which caused this exception

    - #### ODataMessageException

          public ODataMessageException(MessageReference messageReference,
                                       Throwable cause,
                                       String errorCode)

      Creates `ODataMessageException` with given `MessageReference`, cause `Throwable` and error code.
      Parameters:
        `messageReference` - references the message text (and additional values) of this `ODataMessageException`
        `cause` - exception which caused this exception
        `errorCode` - a String with a unique code identifying this exception

    - #### ODataMessageException

          public ODataMessageException(MessageReference messageReference,
                                       String errorCode)

      Creates `ODataMessageException` with given `MessageReference` and error code.
      Parameters:
        `messageReference` - references the message text (and additional values) of this `ODataMessageException`
        `errorCode` - a String with a unique code identifying this exception

  - ### Method Detail

    - #### createMessageReference

          protected static final MessageReference createMessageReference(Class<? extends ODataMessageException> clazz,
                                                                         String messageReferenceKey)

      Creates `MessageReference` objects more conveniently.
      Parameters:
        `clazz` - exception class for message reference
        `messageReferenceKey` - unique (in exception class) key for message reference
      Returns:
        created message-reference instance

    - #### getMessageReference

          public MessageReference getMessageReference()

      Gets the related `MessageReference`.
      Returns:
        the message reference

    - #### getErrorCode

          public String getErrorCode()

      Gets the error code for this `ODataMessageException`. Default is `null`.
      Returns:
        the error code

    - #### getMessage

          public String getMessage()

      Overrides:
        `getMessage` in class `Throwable`

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