Class ErrorMessage


  • public class ErrorMessage
    extends Object
    An error message that kiwi uses in JAX-RS related utilities. This is effectively a replacement for the Dropwizard class of the same name.

    Each instance contains the HTTP status (error) code; the error message; an optional identifier to identify the specific item causing the error (e.g. a primary key); and an optional field/property name for cases when a specific field causes the error.

    • Constructor Detail

      • ErrorMessage

        public ErrorMessage​(String message)
        Create instance with the given message and the default status code (500).
        Parameters:
        message - the error message
      • ErrorMessage

        public ErrorMessage​(javax.ws.rs.core.Response.Status status,
                            String message)
        Create instance with the given HTTP status and message.
        Parameters:
        status - the HTTP response status
        message - the error message
      • ErrorMessage

        public ErrorMessage​(int code,
                            String message)
        Create instance with the given HTTP status code and message.
        Parameters:
        code - the HTTP status code
        message - the error message
      • ErrorMessage

        public ErrorMessage​(int code,
                            String message,
                            String fieldName)
        Create instance with the given HTTP status code, message, and field/property name.
        Parameters:
        code - the HTTP status code
        message - the error message
        fieldName - the field/property name that caused this error
      • ErrorMessage

        @ConstructorProperties({"itemId","code","message","fieldName"})
        public ErrorMessage​(String itemId,
                            int code,
                            String message,
                            String fieldName)
        Create instance with the given item identifier, HTTP status code, message, and field/property name.

        Note that only this constructor has been marked with ConstructorProperties due to an open (as of 2020-09-02) issue in Jackson Databind. See jackson-databind issue #1514.

        Parameters:
        itemId - the unique ID of the item that caused this error
        code - the HTTP status code
        message - the error message
        fieldName - the field/property name that caused this error