Class ErrorResponseUtils

java.lang.Object
org.forgerock.openig.fapi.error.ErrorResponseUtils

public final class ErrorResponseUtils extends Object
Generic utility class which creates Response objects for error during FAPI requests.
  • Method Details

    • errorResponse

      public static Response errorResponse(FapiException fapiException)
      Build a Response from the supplied FapiException.
      Parameters:
      fapiException - the exception used to extract error code and description
      Returns:
      the Response
    • errorResponseAsync

      public static Promise<Response,NeverThrowsException> errorResponseAsync(FapiException fapiException)
      Build a Promise of a Response from the supplied FapiException.
      Parameters:
      fapiException - the exception used to extract error code and description
      Returns:
      the Response
    • errorResponseAsync

      public static Promise<Response,NeverThrowsException> errorResponseAsync(String errorCode, String errorDescription)
      Build a Promise of a Response from the supplied error code and description. The response status will be Status.BAD_REQUEST.
      Parameters:
      errorCode - the error code to use in the response
      errorDescription - the error description to use in the response
      Returns:
      the Promise of a Response
    • errorResponse

      public static Response errorResponse(String errorCode, String errorDescription)
      Build a Response from the supplied error code and description. The response status will be Status.BAD_REQUEST.
      Parameters:
      errorCode - the error code to use in the response
      errorDescription - the error description to use in the response
      Returns:
      the Response
    • errorResponseAsync

      public static Promise<Response,NeverThrowsException> errorResponseAsync(Status status, String error, String errorDescription)
      Build a Promise of a Response with a specific Status and the supplied error code and description.
      Parameters:
      status - the error response HTTP Status
      error - the error field to use in the response - not null
      errorDescription - the error_description field to use in the response - optional
      Returns:
      the Promise of a Response
    • errorResponseAsync

      public static Promise<Response,NeverThrowsException> errorResponseAsync(Status status, String error, Exception exception)
      Build a Promise of a Response with a specific Status and the supplied error code and description based on the exception where, if provided, its message is used.
      Parameters:
      status - the error response HTTP Status
      error - the error field to use in the response - not null
      exception - the plain exception whose message is used as the response errorDescription - optional
      Returns:
      the Promise of a Response
    • errorResponse

      public static Response errorResponse(Status status, String error, String errorDescription)
      Utility method to build an error Response with a specific Status.
      Parameters:
      status - the error response HTTP Status
      error - the error field to use in the response - not null
      errorDescription - the error_description field to use in the response - optional
      Returns:
      the Response
    • errorResponse

      public static Response errorResponse(Status status, String error, String errorDescription, Map<String,Object> additionalFields)
      Utility method to build error Response.
      Parameters:
      status - the error response HTTP Status
      error - the error field to use in the response - not null
      errorDescription - the error_description field to use in the response - optional
      additionalFields - any additional fields to add to the response. Any error or error_description fields would be ignored.
      Returns:
      the Response