BLOG-90 Intergrate error tracking with Sentry #120
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "BLOG-90_sentry_intergated"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
There are several environment variables should be set:
PUBLIC_SENTRY_DSN
SENTRY_AUTH_TOKEN
SENTRY_DSN
If the dsn isn't set, errors won't be sent to Sentry.
Package Changes
No response
Screenshots
Reference
Resolves #90
Checklist
/improve
PR Code Suggestions ✨
Handle
Result
fromexchange_code
The
.unwrap()
call will cause the application to panic ifexchange_code
returns anErr
. This should be handled gracefully by mapping the error to anAuthError::Unexpected
variant to ensure robust error handling and prevent crashes.backend/feature/auth/src/framework/oidc/auth_oidc_service_impl.rs [83]
Suggestion importance[1-10]: 9
__
Why: The
.unwrap()
call can cause the application to panic, which is undesirable in production. Replacing it with.map_err(|e| AuthError::Unexpected(e.into()))?
correctly leverages the newly introducedAuthError::Unexpected
variant for robust error handling.Return correct HTTP status for errors
Several web handlers use a catch-all
_
arm in error matching that converts specific,non-
Unexpected
errors (e.g.,ImageError::NotFound
,PostError::NotFound
) intoHttpResponse::InternalServerError
. These errors often represent client-side issues(4xx status codes) and should return more appropriate HTTP responses (e.g.,
HttpResponse::NotFound()
,HttpResponse::BadRequest()
) instead of a generic 500.Explicitly match these known error types to return correct status codes.
backend/feature/image/src/framework/web/upload_image_handler.rs [85-88]
Suggestion importance[1-10]: 8
__
Why: The current
_
catch-all arm in theupload_image_handler
incorrectly mapsImageError::NotFound
to anHttpResponse::InternalServerError
. Explicitly handlingImageError::NotFound
withHttpResponse::NotFound()
provides a more accurate and helpful API response.