Class ErrorMessage

java.lang.Object
com.yahoo.processing.request.ErrorMessage
com.yahoo.search.result.ErrorMessage
All Implemented Interfaces:
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
  • Field Details

    • NULL_QUERY

      public static final int NULL_QUERY
    • timeoutCode

      public static final int timeoutCode
    • emptyDocsumsCode

      public static final int emptyDocsumsCode
  • Constructor Details

    • ErrorMessage

      public ErrorMessage(int code, String message)
    • ErrorMessage

      public ErrorMessage(int code, String message, 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, String message, String detailedMessage, 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 Details

    • createNoBackendsInService

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public static ErrorMessage createUnauthorized(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(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(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(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(String detailedMessage)
      Creates an error analog to HTTP internal server error. If this error is present, a HTTP layer will return 500.
    • createInternalServerError

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

      public static ErrorMessage createSearchReplyError(String detailedMessage)
      Wraps an error message received in a SearchReply packet
    • createDocsumReplyError

      public static ErrorMessage createDocsumReplyError(String detailedMessage)
      Wraps an error message received in a DocsumReply packet
    • setSource

      public void setSource(String source)
      Sets the source producing this error
    • getSource

      public 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(Object o)
      Overrides:
      equals in class com.yahoo.processing.request.ErrorMessage
    • toString

      public 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.