Interceptor that catches all errors in the request pipeline. Its job is to sanitize errors and finalize tracing before passing to the Exception Filter.
- Catches any error from the request pipeline
- Sanitizes external API errors (Axios)
- Adds context (class/method where error occurred)
- Finalizes tracing with error status
- Re-throws to Exception Filter
| Step | Where | Tracing Action |
|---|---|---|
| 1 | Request arrives | tracing.start() |
| 2 | Processing... | tracing.addAttribute() |
| 3 | Error occurs | Interceptor catches |
| 4 | This interceptor | tracing.setStatus(ERROR) |
| 5 | This interceptor | tracing.finish() ✓ |
| 6 | Exception Filter | Formats response |
Axios errors are sanitized to expose a consistent interface:
// Before: Raw Axios error with nested response
error.response.data.error.message
// After: Sanitized with getResponse() and getStatus()
error.getResponse() // Returns error data
error.getStatus() // Returns status code// Priority order for status code:
1. error.response.data.error.code (nested)
2. error.response.data.code
3. error.response.status
4. error.status
5. 500 (fallback)| Feature | Description |
|---|---|
| Purpose | Catch errors, finalize tracing |
| Sanitizes | Axios external API errors |
| Adds | traceid, context |
| Finalizes | Tracing span with ERROR status |
Exception Handler Interceptor - Error pipeline that closes tracing spans.