feat: Report application errors with details#487
Closed
erezrokah wants to merge 1 commit intocloudquery:mainfrom
Closed
feat: Report application errors with details#487erezrokah wants to merge 1 commit intocloudquery:mainfrom
erezrokah wants to merge 1 commit intocloudquery:mainfrom
Conversation
erezrokah
commented
Dec 11, 2022
clients/destination.go
Outdated
| if err != nil { | ||
| return fmt.Errorf("failed to CloseAndRecv client: %w", err) | ||
| st := status.Convert(err) | ||
| errorWithDetails := err.Error() |
Member
Author
There was a problem hiding this comment.
I'm concatenating errors into one string, but we can decide to do something else
erezrokah
commented
Dec 11, 2022
| s.Logger.Error().Err(err).Msg("failed to unmarshal resource. failed to wait for plugin") | ||
| errWithDetails := addErrorDetails(errors.New("failed to unmarshal resource"), unmarshalError.Error()) | ||
| if writeError := eg.Wait(); writeError != nil { | ||
| errWithDetails = addErrorDetails(errors.New("plugin write failed and failed to unmarshal resource"), writeError.Error()) |
Member
Author
There was a problem hiding this comment.
Details is an array so we can send multiple errors
erezrokah
commented
Dec 11, 2022
| return nil | ||
| } | ||
| return ctx.Err() | ||
| return addErrorDetails(errors.New("context error"), ctxError.Error()) |
Member
Author
There was a problem hiding this comment.
This is only an example, we should be using #486 instead
⏱️ Benchmark resultsComparing with 8dcbe8d
|
f6bb7f0 to
0de7daa
Compare
erezrokah
commented
Dec 11, 2022
| _, err = saveClient.CloseAndRecv() | ||
| if err != nil { | ||
| return fmt.Errorf("failed to CloseAndRecv client: %w", err) | ||
| st := status.Convert(err) |
Member
Author
There was a problem hiding this comment.
We should probably put this into a function and replace #477 so we can get both the message and the details
This was referenced Dec 11, 2022
| st := status.Convert(err) | ||
| errorWithDetails := st.Message() | ||
| if len(st.Details()) > 0 { | ||
| errorWithDetails += "\nDetails:\n" |
Member
Author
There was a problem hiding this comment.
We can try good catch. Please note this is only one example on how to report the errors. We might want to do something else than strings concatenation
0de7daa to
bfa9acf
Compare
Member
Author
|
Closing this POC for now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to #462.
Draft PR as meant to serve as an example on how to improve error reporting and handling.
I'm using
errdetailsbut we could also write our own protobuf messages instead (don't think we should).Use the following steps to ensure your PR is ready to be reviewed
go fmtto format your code 🖊golangci-lint run🚨 (install golangci-lint here)