refactor: migrate errors.As to errors.AsType (Go 1.26 generics)#2959
refactor: migrate errors.As to errors.AsType (Go 1.26 generics)#2959Piwriw wants to merge 1 commit into
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @Piwriw on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
There was a problem hiding this comment.
Code Review
Using status.FromError directly on the error in packages/shared/pkg/storage/storage_google.go breaks detection of wrapped gRPC errors because status.FromError only performs a direct type assertion and does not traverse the error chain, which is a regression from the original errors.As implementation. To preserve the unwrapping behavior, use errors.AsType with the grpcStatusProvider interface.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if s, ok := status.FromError(err); ok { | ||
| return s.Code() == codes.ResourceExhausted | ||
| } |
There was a problem hiding this comment.
Using status.FromError directly on the error breaks detection of wrapped gRPC errors because status.FromError only performs a direct type assertion and does not traverse the error chain. This is a regression from the original errors.As implementation which correctly unwrapped the error chain. To preserve the unwrapping behavior while adopting the new pattern, use errors.AsType with the grpcStatusProvider interface.
type grpcStatusProvider interface {
GRPCStatus() *status.Status
}
if se, ok := errors.AsType[grpcStatusProvider](err);"ok {
return se.GRPCStatus().Code() == codes.ResourceExhausted
}References
- Focus on error handling and correctness issues, skipping style/nit comments. (link)
Signed-off-by: joohwan <piwriw@163.com>
ec0fddf to
66ac0ab
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @Piwriw on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
|
/cla recheck |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
refactor: migrate errors.As to errors.AsType (Go 1.26 generics)