Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Tufin/oasdiff
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Feb 5, 2024
2 parents 3f4730f + a31fd62 commit 63bd9f0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 127 deletions.
75 changes: 0 additions & 75 deletions checker/bc_diff.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/oasdiff/telemetry v0.1.2
github.com/stretchr/testify v1.8.4
github.com/yargevad/filepathx v1.0.0
github.com/yuin/goldmark v1.6.0
github.com/yuin/goldmark v1.7.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4d
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc=
github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA=
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=
github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.0 h1:EfOIvIMZIzHdB/R/zVrikYLPPwJlfMcNczJFMs1m6sA=
github.com/yuin/goldmark v1.7.0/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
102 changes: 54 additions & 48 deletions internal/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,86 +11,92 @@ type ReturnError struct {
Code int
}

const generalExecutionErr = 100

func getErrInvalidFlags(err error) *ReturnError {
return &ReturnError{
error: err,
Code: 101,
}
return getError(
err,
101,
)
}

func getErrFailedToLoadSpec(what string, source *load.Source, err error) *ReturnError {
return &ReturnError{
error: fmt.Errorf("failed to load %s spec from %s with %v", what, source.Out(), err),
Code: 102,
}
return getError(
fmt.Errorf("failed to load %s spec from %s with %v", what, source.Out(), err),
102,
)
}

func getErrFailedToLoadSpecs(what string, path string, err error) *ReturnError {
return &ReturnError{
error: fmt.Errorf("failed to load %s specs from glob %q with %v", what, path, err),
Code: 103,
}
return getError(
fmt.Errorf("failed to load %s specs from glob %q with %v", what, path, err),
103,
)
}

func getErrDiffFailed(err error) *ReturnError {
return &ReturnError{
error: fmt.Errorf("diff failed with %v", err),
Code: 104,
}
return getError(
fmt.Errorf("diff failed with %v", err),
104,
)
}

func getErrFailedPrint(what string, err error) *ReturnError {
return &ReturnError{
error: fmt.Errorf("failed to print %q with %v", what, err),
Code: 105,
}
return getError(
fmt.Errorf("failed to print %q with %v", what, err),
105,
)
}

func getErrUnsupportedDiffFormat(format string) *ReturnError {
return &ReturnError{
error: fmt.Errorf("format %q is not supported by \"diff\"", format),
Code: 109,
}
return getError(
fmt.Errorf("format %q is not supported by \"diff\"", format),
109,
)
}

func getErrUnsupportedSummaryFormat(format string) *ReturnError {
return &ReturnError{
error: fmt.Errorf("format %q is not supported by \"summary\"", format),
Code: 110,
}
return getError(
fmt.Errorf("format %q is not supported by \"summary\"", format),
110,
)
}

func getErrUnsupportedChangelogFormat(format string) *ReturnError {
return &ReturnError{
error: fmt.Errorf("format %q is not supported by \"changelog\"", format),
Code: 111,
}
return getError(
fmt.Errorf("format %q is not supported by \"changelog\"", format),
111,
)
}

func getErrUnsupportedBreakingChangesFormat(format string) *ReturnError {
return &ReturnError{
error: fmt.Errorf("format %q is not supported by \"breaking\"", format),
Code: 112,
}
return getError(
fmt.Errorf("format %q is not supported by \"breaking\"", format),
112,
)
}

func getErrUnsupportedChecksFormat(format string) *ReturnError {
return &ReturnError{
error: fmt.Errorf("format %q is not supported with \"checks\"", format),
Code: 113,
}
return getError(
fmt.Errorf("format %q is not supported with \"checks\"", format),
113,
)
}

func getErrInvalidColorMode(err error) *ReturnError {
return &ReturnError{
error: err,
Code: 114,
}
return getError(
err,
114,
)
}

func getErrCantProcessIgnoreFile(what string, err error) *ReturnError {
return &ReturnError{
error: fmt.Errorf("can't process %s ignore file %v", what, err),
Code: 121,
}
return getError(
fmt.Errorf("can't process %s ignore file %v", what, err),
121,
)
}

func getError(err error, code int) *ReturnError {
return &ReturnError{err, code}
}
2 changes: 1 addition & 1 deletion internal/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func run(cmd *cobra.Command) int {
if ret := getReturnValue(cmd); ret != 0 {
return ret
}
return 100
return generalExecutionErr
}

return getReturnValue(cmd)
Expand Down

0 comments on commit 63bd9f0

Please sign in to comment.