Class ErrorMessage

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class ErrorMessage
    extends com.yahoo.processing.request.ErrorMessage
    An error message with a code. Use create methods to create messages. The identity of an error message is determined by its values.
    Author:
    bratseth
    • Constructor Summary

      Constructors 
      Constructor Description
      ErrorMessage​(int code, java.lang.String message)  
      ErrorMessage​(int code, java.lang.String message, java.lang.String detailedMessage)
      Creates an application specific error message with an application specific code.
      ErrorMessage​(int code, java.lang.String message, java.lang.String detailedMessage, java.lang.Throwable cause)
      Creates an application specific error message with an application specific code and a stack trace.
    • Field Detail

      • NULL_QUERY

        public static final int NULL_QUERY
      • timeoutCode

        public static final int timeoutCode
      • emptyDocsumsCode

        public static final int emptyDocsumsCode
    • Constructor Detail

      • ErrorMessage

        public ErrorMessage​(int code,
                            java.lang.String message)
      • ErrorMessage

        public ErrorMessage​(int code,
                            java.lang.String message,
                            java.lang.String detailedMessage)
        Creates an application specific error message with an application specific code. If the error results from an exception a message which includes information from all nested (cause) exceptions can be generated using com.yahoo.protect.Exceptions.toMessageString(exception).
      • ErrorMessage

        public ErrorMessage​(int code,
                            java.lang.String message,
                            java.lang.String detailedMessage,
                            java.lang.Throwable cause)
        Creates an application specific error message with an application specific code and a stack trace. This should only be used when there is useful information in the cause, i.e when the exception is not expected. Applications rarely need to handle unexpected exceptions as this is done by the framework.
    • Method Detail

      • createNoBackendsInService

        public static ErrorMessage createNoBackendsInService​(java.lang.String detailedMessage)
        Creates an error message indicating that some backend service is unreachable
      • createNullQuery

        public static ErrorMessage createNullQuery​(java.lang.String detailedMessage)
        Creates an error message indicating that a null query was attempted evaluated
      • createRequestTooLarge

        public static ErrorMessage createRequestTooLarge​(java.lang.String detailedMessage)
        Creates an error message indicating that the request is too large
      • createIllegalQuery

        public static ErrorMessage createIllegalQuery​(java.lang.String detailedMessage)
        Creates an error message indicating that an illegal query was attempted evaluated.
      • createInvalidQueryParameter

        public static ErrorMessage createInvalidQueryParameter​(java.lang.String detailedMessage)
        Creates an error message indicating that an invalid request parameter was received.
      • createInvalidQueryParameter

        public static ErrorMessage createInvalidQueryParameter​(java.lang.String detailedMessage,
                                                               java.lang.Throwable cause)
        Creates an error message indicating that an invalid request parameter was received.
      • createUnspecifiedError

        public static ErrorMessage createUnspecifiedError​(java.lang.String detailedMessage)
        Creates a generic message used when there is no information available on the category of the error.
      • createUnspecifiedError

        public static ErrorMessage createUnspecifiedError​(java.lang.String detailedMessage,
                                                          java.lang.Throwable cause)
        Creates a generic message used when there is no information available on the category of the error.
      • createErrorInPluginSearcher

        public static ErrorMessage createErrorInPluginSearcher​(java.lang.String detailedMessage)
        Creates a general error from an application components.
      • createErrorInPluginSearcher

        public static ErrorMessage createErrorInPluginSearcher​(java.lang.String detailedMessage,
                                                               java.lang.Throwable cause)
        Creates a general error from an application component.
      • createInvalidQueryTransformation

        public static ErrorMessage createInvalidQueryTransformation​(java.lang.String detailedMessage)
        Creates an error indicating that an invalid query transformation was attempted.
      • createServerIsMisconfigured

        public static ErrorMessage createServerIsMisconfigured​(java.lang.String detailedMessage)
        Creates an error indicating that the server is misconfigured
      • createBackendCommunicationError

        public static ErrorMessage createBackendCommunicationError​(java.lang.String detailedMessage)
        Creates an error indicating that there was a general error communicating with a backend service.
      • createNoAnswerWhenPingingNode

        public static ErrorMessage createNoAnswerWhenPingingNode​(java.lang.String detailedMessage)
        Creates an error indicating that a node could not be pinged.
      • createTimeout

        public static ErrorMessage createTimeout​(java.lang.String detailedMessage)
        Creates an error indicating that a request to a backend timed out.
      • createEmptyDocsums

        public static ErrorMessage createEmptyDocsums​(java.lang.String detailedMessage)
        Creates an error indicating that a request to a backend returned empty document content data.
      • createUnauthorized

        public static ErrorMessage createUnauthorized​(java.lang.String detailedMessage)
        Creates an error indicating that the requestor is not authorized to perform the requested operation. If this error is present, a HTTP layer will return 401.
      • createForbidden

        public static ErrorMessage createForbidden​(java.lang.String detailedMessage)
        Creates an error indicating that a forbidden operation was requested. If this error is present, a HTTP layer will return 403.
      • createNotFound

        public static ErrorMessage createNotFound​(java.lang.String detailedMessage)
        Creates an error indicating that the requested resource was not found. If this error is present, a HTTP layer will return 404.
      • createBadRequest

        public static ErrorMessage createBadRequest​(java.lang.String detailedMessage)
        Creates an error analog to HTTP bad request. If this error is present, a HTTP layer will return 400.
      • createInternalServerError

        public static ErrorMessage createInternalServerError​(java.lang.String detailedMessage)
        Creates an error analog to HTTP internal server error. If this error is present, a HTTP layer will return 500.
      • setSource

        public void setSource​(java.lang.String source)
        Sets the source producing this error
      • getSource

        public java.lang.String getSource()
        Returns the source producing this error, or null if no source is specified
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class com.yahoo.processing.request.ErrorMessage
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class com.yahoo.processing.request.ErrorMessage
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class com.yahoo.processing.request.ErrorMessage
      • clone

        public ErrorMessage clone()
        Overrides:
        clone in class com.yahoo.processing.request.ErrorMessage
      • from

        public static ErrorMessage from​(com.yahoo.processing.request.ErrorMessage error)
        Returns the given error message as this type. If it already is, this is a cast of the given instance. Otherwise this creates a new instance having the same payload as the given instance.