Skip to content

fix: improve error classification for better observability (#618)#941

Open
rajprakhar07 wants to merge 2 commits into
imDarshanGK:mainfrom
rajprakhar07:fix/error-classification-618
Open

fix: improve error classification for better observability (#618)#941
rajprakhar07 wants to merge 2 commits into
imDarshanGK:mainfrom
rajprakhar07:fix/error-classification-618

Conversation

@rajprakhar07
Copy link
Copy Markdown

Closes #618

What I did

  • Added ErrorCategory enum (CLIENT, SERVER, PROVIDER)
  • Added ERROR_CATEGORY_MAP to map HTTP status codes to categories
  • Added error_classification_middleware that attaches X-Error-Category header to all error responses
  • Registered middleware in main.py
  • Errors are now logged with category for better observability and triage

Files Changed

  • backend/app/middleware.py — added ErrorCategory enum and middleware
  • backend/app/main.py — registered error_classification_middleware

Type

  • Bug fix / Enhancement

@rajprakhar07
Copy link
Copy Markdown
Author

Tested the implementation locally:
curl -i http://127.0.0.1:8000/nonexistent-route
HTTP/1.1 404 Not Found
x-error-category: client_error
Middleware is working correctly — errors are classified and X-Error-Category header is attached to all error responses. Kindly review and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error classification for better observability

1 participant