Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mscno committed Aug 28, 2024
1 parent 70cc28c commit 4302586
Show file tree
Hide file tree
Showing 26 changed files with 117 additions and 13 deletions.
2 changes: 1 addition & 1 deletion already_exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func AlreadyExists(message string, KVs ...interface{}) error {
}

func AlreadyExistsf(format string, a ...interface{}) error {
return oops.Code(ErrAlreadyExists).Errorf(format, a...)
return oops.Code(ErrAlreadyExists).Wrap(fmt.Errorf(format, a...))
}

func AlreadyExistsBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions already_exists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowAlreadyExists(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestAlreadyExistsf(t *testing.T) {
err := AlreadyExistsf("something happened: %s", "reason")
ok := IsAlreadyExists(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion deadline_exceeded.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func DeadlineExceeded(message string, KVs ...interface{}) error {
}

func DeadlineExceededf(format string, a ...interface{}) error {
return oops.Code(ErrDeadlineExceeded).Errorf(format, a...)
return oops.Code(ErrDeadlineExceeded).Wrap(fmt.Errorf(format, a...))
}

func DeadlineExceededBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions deadline_exceeded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowDeadlineExceeded(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestDeadlineExceededf(t *testing.T) {
err := DeadlineExceededf("something happened: %s", "reason")
ok := IsDeadlineExceeded(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion failed_precondition.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func FailedPrecondition(message string, KVs ...interface{}) error {
}

func FailedPreconditionf(format string, a ...interface{}) error {
return oops.Code(ErrFailedPrecondition).Errorf(format, a...)
return oops.Code(ErrFailedPrecondition).Wrap(fmt.Errorf(format, a...))
}

func FailedPreconditionBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions failed_precondition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowFailedPrecondition(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestFailedPreconditionf(t *testing.T) {
err := FailedPreconditionf("something happened: %s", "reason")
ok := IsFailedPrecondition(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion generate/error.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func {{ .ErrorName }}(message string, KVs ...interface{}) error {
}

func {{ .ErrorName }}f(format string, a ...interface{}) error {
return oops.Code(Err{{ .ErrorName }}).Errorf(format, a...)
return oops.Code(Err{{ .ErrorName }}).Wrap(fmt.Errorf(format, a...))
}

func {{ .ErrorName }}Builder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions generate/error_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrow{{ .ErrorName }}(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func Test{{ .ErrorName }}f(t *testing.T) {
err := {{ .ErrorName }}f("something happened: %s", "reason")
ok := Is{{ .ErrorName }}(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Internal(message string, KVs ...interface{}) error {
}

func Internalf(format string, a ...interface{}) error {
return oops.Code(ErrInternal).Errorf(format, a...)
return oops.Code(ErrInternal).Wrap(fmt.Errorf(format, a...))
}

func InternalBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowInternal(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestInternalf(t *testing.T) {
err := Internalf("something happened: %s", "reason")
ok := IsInternal(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion invalid_argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func InvalidArgument(message string, KVs ...interface{}) error {
}

func InvalidArgumentf(format string, a ...interface{}) error {
return oops.Code(ErrInvalidArgument).Errorf(format, a...)
return oops.Code(ErrInvalidArgument).Wrap(fmt.Errorf(format, a...))
}

func InvalidArgumentBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions invalid_argument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowInvalidArgument(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestInvalidArgumentf(t *testing.T) {
err := InvalidArgumentf("something happened: %s", "reason")
ok := IsInvalidArgument(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion not_found.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NotFound(message string, KVs ...interface{}) error {
}

func NotFoundf(format string, a ...interface{}) error {
return oops.Code(ErrNotFound).Errorf(format, a...)
return oops.Code(ErrNotFound).Wrap(fmt.Errorf(format, a...))
}

func NotFoundBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions not_found_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowNotFound(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestNotFoundf(t *testing.T) {
err := NotFoundf("something happened: %s", "reason")
ok := IsNotFound(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion permission_denied.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func PermissionDenied(message string, KVs ...interface{}) error {
}

func PermissionDeniedf(format string, a ...interface{}) error {
return oops.Code(ErrPermissionDenied).Errorf(format, a...)
return oops.Code(ErrPermissionDenied).Wrap(fmt.Errorf(format, a...))
}

func PermissionDeniedBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions permission_denied_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowPermissionDenied(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestPermissionDeniedf(t *testing.T) {
err := PermissionDeniedf("something happened: %s", "reason")
ok := IsPermissionDenied(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion resource_exhausted.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func ResourceExhausted(message string, KVs ...interface{}) error {
}

func ResourceExhaustedf(format string, a ...interface{}) error {
return oops.Code(ErrResourceExhausted).Errorf(format, a...)
return oops.Code(ErrResourceExhausted).Wrap(fmt.Errorf(format, a...))
}

func ResourceExhaustedBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions resource_exhausted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowResourceExhausted(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestResourceExhaustedf(t *testing.T) {
err := ResourceExhaustedf("something happened: %s", "reason")
ok := IsResourceExhausted(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion unauthenticated.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Unauthenticated(message string, KVs ...interface{}) error {
}

func Unauthenticatedf(format string, a ...interface{}) error {
return oops.Code(ErrUnauthenticated).Errorf(format, a...)
return oops.Code(ErrUnauthenticated).Wrap(fmt.Errorf(format, a...))
}

func UnauthenticatedBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions unauthenticated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowUnauthenticated(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestUnauthenticatedf(t *testing.T) {
err := Unauthenticatedf("something happened: %s", "reason")
ok := IsUnauthenticated(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion unavailable.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Unavailable(message string, KVs ...interface{}) error {
}

func Unavailablef(format string, a ...interface{}) error {
return oops.Code(ErrUnavailable).Errorf(format, a...)
return oops.Code(ErrUnavailable).Wrap(fmt.Errorf(format, a...))
}

func UnavailableBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions unavailable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowUnavailable(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestUnavailablef(t *testing.T) {
err := Unavailablef("something happened: %s", "reason")
ok := IsUnavailable(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion unimplemented.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Unimplemented(message string, KVs ...interface{}) error {
}

func Unimplementedf(format string, a ...interface{}) error {
return oops.Code(ErrUnimplemented).Errorf(format, a...)
return oops.Code(ErrUnimplemented).Wrap(fmt.Errorf(format, a...))
}

func UnimplementedBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions unimplemented_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowUnimplemented(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestUnimplementedf(t *testing.T) {
err := Unimplementedf("something happened: %s", "reason")
ok := IsUnimplemented(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}
2 changes: 1 addition & 1 deletion unknown.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Unknown(message string, KVs ...interface{}) error {
}

func Unknownf(format string, a ...interface{}) error {
return oops.Code(ErrUnknown).Errorf(format, a...)
return oops.Code(ErrUnknown).Wrap(fmt.Errorf(format, a...))
}

func UnknownBuilder() oops.OopsErrorBuilder {
Expand Down
8 changes: 8 additions & 0 deletions unknown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func TestThrowUnknown(t *testing.T) {

assert.Equal(t, err.Error(), "cannot create 'sam' of kind 'user'")
}

func TestUnknownf(t *testing.T) {
err := Unknownf("something happened: %s", "reason")
ok := IsUnknown(err)
assert.True(t, ok)

assert.Equal(t, err.Error(), "something happened: reason")
}

0 comments on commit 4302586

Please sign in to comment.