-
Notifications
You must be signed in to change notification settings - Fork 432
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
feat(api,sdk): Fix some issue with error wrap #3493
Conversation
@@ -104,15 +104,15 @@ func createNewVulnerabilityReport(db gorp.SqlExecutor, cache cache.Store, proj * | |||
|
|||
// Get summary from previous run | |||
previousRunReport, err := loadPreviousRunVulnerabilityReport(db, nr) | |||
if err != nil && err != sdk.ErrNotFound { | |||
if err != nil && sdk.ErrorIs(err, sdk.ErrNotFound) { |
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.
fix
return sdk.WrapError(err, "Unable to get previous vulnerability report") | ||
} | ||
nodeRunReport.Report.PreviousRunSummary = previousRunReport | ||
|
||
// Get summary from default branch | ||
if defaultBranch != "" && defaultBranch != nr.VCSBranch { | ||
defaultBranchReport, err := loadLatestRunVulnerabilityReport(db, nr, defaultBranch) | ||
if err != nil && err != sdk.ErrNotFound { | ||
if err != nil && sdk.ErrorIs(err, sdk.ErrNotFound) { |
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.
fix
sdk/exportentities/common.go
Outdated
@@ -9,6 +9,7 @@ import ( | |||
"strings" | |||
"time" | |||
|
|||
"github.com/ovh/cds/sdk" |
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.
wrong place
return service.WriteJSON(w, msgListString, myError.Status) | ||
globalError = sdk.WrapError(globalError, "Unable to import environment %s", eenv.Name) | ||
if sdk.ErrorIs(globalError, sdk.ErrUnknownError) { | ||
return globalError |
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's not exactly the same thing here...
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.
I created a sdk.ErrorIsUnknown and updated the ErrorIs to return true is an error not known (not from our sdk) is compared with ErrUnknownError.
engine/api/pipeline_import.go
Outdated
if ok { | ||
return service.WriteJSON(w, msgListString, myError.Status) | ||
globalError = sdk.WrapError(globalError, "Unable to import pipeline") | ||
if sdk.ErrorIs(globalError, sdk.ErrUnknownError) { |
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.
we have to discuss about it
- Add cause in http error message - Replace all compare to sdk.Err by sdk.ErrorIs - Create empty error and fmt.Errorf when wrapping sdk.Err to prevent message duplication - Improve error log for some import handlers
4508ae4
to
b33d7f8
Compare
message duplication
@ovh/cds