Skip to content
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

Merged
merged 9 commits into from
Oct 29, 2018

Conversation

richardlt
Copy link
Member

  • 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
  1. Description
  2. Related issues
  3. About tests
  4. Mentions

@ovh/cds

@@ -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) {
Copy link
Member Author

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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/ovh/cds/sdk"
Copy link
Collaborator

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
Copy link
Member

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...

Copy link
Member Author

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.

if ok {
return service.WriteJSON(w, msgListString, myError.Status)
globalError = sdk.WrapError(globalError, "Unable to import pipeline")
if sdk.ErrorIs(globalError, sdk.ErrUnknownError) {
Copy link
Member

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

@richardlt richardlt changed the title feat(api,sdk): Fix some issue with error wrap WIP feat(api,sdk): Fix some issue with error wrap Oct 24, 2018
@richardlt richardlt changed the title WIP feat(api,sdk): Fix some issue with error wrap feat(api,sdk): Fix some issue with error wrap Oct 24, 2018
@richardlt richardlt force-pushed the feat-improve-errors-next branch from 4508ae4 to b33d7f8 Compare October 24, 2018 12:29
@ovh ovh deleted a comment from ovh-cds Oct 24, 2018
@ovh ovh deleted a comment from ovh-cds Oct 24, 2018
@sguiheux sguiheux merged commit 2e9a792 into master Oct 29, 2018
@fsamin fsamin deleted the feat-improve-errors-next branch November 15, 2018 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants