mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
fix: improve error handling in the error hook
- Updated the error handling logic in the tonic error hook to unwrap nested errors, ensuring that the most relevant error message is returned. - Enhanced the clarity of the error response by directly using the unwrapped error message, improving debugging and user feedback.
This commit is contained in:
@@ -18,8 +18,12 @@ import (
|
||||
|
||||
func init() {
|
||||
tonic.SetErrorHook(func(context *gin.Context, err error) (int, interface{}) {
|
||||
unwrappedErr := errors.Unwrap(err)
|
||||
if unwrappedErr != nil {
|
||||
err = unwrappedErr
|
||||
}
|
||||
response := gin.H{
|
||||
"error": errors.Unwrap(err).Error(),
|
||||
"error": err.Error(),
|
||||
}
|
||||
status := http.StatusInternalServerError
|
||||
constErr, ok := errors.AsType[errors.ConstError](err)
|
||||
|
||||
Reference in New Issue
Block a user