-
Notifications
You must be signed in to change notification settings - Fork 8.3k
fix: Unwrap joinErr in gin.Error() #4260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi, I am ready for a PR review. |
e17500e
to
0790c13
Compare
Hi, I am ready for a PR review. |
Hi @appleboy , I would like to make a request to trigger the github action workflow. |
1 similar comment
Hi @appleboy , I would like to make a request to trigger the github action workflow. |
if multi, ok := err.(interface{ Unwrap() []error }); ok { | ||
for _, e := range multi.Unwrap() { | ||
result = append(result, unwrapJoinErr(e)...) | ||
} | ||
} else if single := errors.Unwrap(err); single != nil { | ||
result = append(result, unwrapJoinErr(single)...) | ||
} else { | ||
result = append(result, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use switch syntax or a single if statement instead of ifelse.
if err == nil { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is prone to panic. Maybe returning an empty slice would be better
for _, msg := range a { | ||
for _, err := range unwrapJoinErr(msg.Err) { | ||
fmt.Fprintf(&buffer, "Error #%02d: %s\n", count, err) | ||
if msg.Meta != nil { | ||
fmt.Fprintf(&buffer, " Meta: %v\n", msg.Meta) | ||
} | ||
count++ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nesting of loops here seems unnecessary
Issue Reference
Closes: #4237
master
Test Report
20250607_gin_tests_0790c13.pdf
Page 22 ->