Class GlobalExceptionMapper

java.lang.Object
ai.pipestream.module.pipelineprobe.GlobalExceptionMapper

public class GlobalExceptionMapper extends Object
Global exception mapper that captures unhandled errors, records them in LastErrorTracker, and returns a structured JSON 500 response. WebApplicationException (404s, etc.) are re-thrown to preserve normal JAX-RS behavior.
  • Constructor Details

    • GlobalExceptionMapper

      public GlobalExceptionMapper()
      Creates the global exception mapper. Instances are managed by the JAX-RS runtime.
  • Method Details

    • mapUnexpectedErrors

      public jakarta.ws.rs.core.Response mapUnexpectedErrors(Throwable throwable)
      Maps an unhandled throwable to an HTTP response.

      A WebApplicationException is unwrapped and its own response is returned unchanged, preserving normal JAX-RS behavior (e.g. 404s). An IllegalArgumentException is mapped to a 400 Bad Request carrying the exception message. Any other throwable is recorded in LastErrorTracker (keyed by the top stack-trace frame), logged, and returned as a structured JSON 500 Internal Server Error.

      Parameters:
      throwable - the unhandled error raised while processing the request
      Returns:
      the JAX-RS response to send to the client