Class BusRefusal

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.apache.juneau.console.bus.BusRefusal
All Implemented Interfaces:
Serializable

public final class BusRefusal extends Exception
A named refusal from the bus: the session POST's 400/403/429/501 answers and the codec's bus:bad-frame. The message is fixed server text; denied() lists the topic names the caller requested, which is the only caller input in a refusal.
Example:

try { BusSession s = bus.openSession(req, body); ... } catch (BusRefusal e) { res.setStatus(e.status()); e.retryAfterSeconds().ifPresent(s -> res.setHeader("Retry-After", String.valueOf(s))); return e.toJson(); // {"code":"bus:topic-denied","message":"...","denied":["ops.secret"]} }

Since:
10.0.0
See Also:
  • Field Details

  • Constructor Details

    • BusRefusal

      public BusRefusal(int status, String code, String message, List<String> denied, int retryAfterSeconds)
      Constructor.
      Parameters:
      status - The HTTP status.
      code - The bus:* code.
      message - Fixed server text.
      denied - The denied topics, for bus:topic-denied. Can be null.
      retryAfterSeconds - Retry-After seconds, or 0 for none.
  • Method Details

    • status

      public int status()
      Returns:
      The HTTP status.
    • code

      public String code()
      Returns:
      The bus:* code.
    • denied

      public List<String> denied()
      Returns:
      The denied topics (empty unless bus:topic-denied).
    • retryAfterSeconds

      Returns:
      The Retry-After seconds, if any.
    • toJson

      public JsonMap toJson()
      The refusal body: {code, message, denied?}.
      Returns:
      A new map.