Class ProblemException

All Implemented Interfaces:
Serializable

public class ProblemException extends RuntimeException
A RuntimeException that carries an RFC 7807 Problem payload.

Lets handlers throw a custom problem without manually building a BasicHttpException:

throw new ProblemException( Problem.fromStatus(403, "Insufficient credit", "Balance 30 < cost 50") .set("balance", 30) );

The wrapped Problem is recovered via getProblem(). Lives in the bean module (no juneau-rest-server dep); the server-side processor recognises ProblemException and unwraps it for serialization.

See Also:
See Also:
  • Constructor Details

    • ProblemException

      public ProblemException(Problem problem)
      Constructor.
      Parameters:
      problem - The problem payload to carry. May be null, though callers should normally supply a populated Problem.
  • Method Details

    • of

      public static ProblemException of(Problem problem)
      Convenience factory.
      Parameters:
      problem - The problem payload to carry. May be null.
      Returns:
      A new ProblemException wrapping problem.
    • getProblem

      public Problem getProblem()
      Returns the wrapped Problem payload.
      Returns:
      The problem payload, or null if none was supplied at construction.