Skip to content

Commit

Permalink
add builder
Browse files Browse the repository at this point in the history
  • Loading branch information
mscno committed Mar 23, 2024
1 parent d5642ec commit d7942cc
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions already_exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func AlreadyExists(format string, a ...interface{}) error {
return oops.Code(ErrAlreadyExists).Errorf(format, a...)
}

func AlreadyExistsBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrAlreadyExists)
}

func ToAlreadyExists(parent error, format string, a ...interface{}) error {
return oops.Code(ErrAlreadyExists).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions deadline_exceeded.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func DeadlineExceeded(format string, a ...interface{}) error {
return oops.Code(ErrDeadlineExceeded).Errorf(format, a...)
}

func DeadlineExceededBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrDeadlineExceeded)
}

func ToDeadlineExceeded(parent error, format string, a ...interface{}) error {
return oops.Code(ErrDeadlineExceeded).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions failed_precondition.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func FailedPrecondition(format string, a ...interface{}) error {
return oops.Code(ErrFailedPrecondition).Errorf(format, a...)
}

func FailedPreconditionBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrFailedPrecondition)
}

func ToFailedPrecondition(parent error, format string, a ...interface{}) error {
return oops.Code(ErrFailedPrecondition).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions generate/error.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func {{ .ErrorName }}(format string, a ...interface{}) error {
return oops.Code(Err{{ .ErrorName }}).Errorf(format, a...)
}

func {{ .ErrorName }}Builder() oops.OopsErrorBuilder {
return oops.Code(Err{{ .ErrorName }})
}

func To{{ .ErrorName }}(parent error, format string, a ...interface{}) error {
return oops.Code(Err{{ .ErrorName }}).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func Internal(format string, a ...interface{}) error {
return oops.Code(ErrInternal).Errorf(format, a...)
}

func InternalBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrInternal)
}

func ToInternal(parent error, format string, a ...interface{}) error {
return oops.Code(ErrInternal).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions invalid_argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func InvalidArgument(format string, a ...interface{}) error {
return oops.Code(ErrInvalidArgument).Errorf(format, a...)
}

func InvalidArgumentBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrInvalidArgument)
}

func ToInvalidArgument(parent error, format string, a ...interface{}) error {
return oops.Code(ErrInvalidArgument).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions not_found.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func NotFound(format string, a ...interface{}) error {
return oops.Code(ErrNotFound).Errorf(format, a...)
}

func NotFoundBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrNotFound)
}

func ToNotFound(parent error, format string, a ...interface{}) error {
return oops.Code(ErrNotFound).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions permission_denied.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func PermissionDenied(format string, a ...interface{}) error {
return oops.Code(ErrPermissionDenied).Errorf(format, a...)
}

func PermissionDeniedBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrPermissionDenied)
}

func ToPermissionDenied(parent error, format string, a ...interface{}) error {
return oops.Code(ErrPermissionDenied).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions resource_exhausted.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func ResourceExhausted(format string, a ...interface{}) error {
return oops.Code(ErrResourceExhausted).Errorf(format, a...)
}

func ResourceExhaustedBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrResourceExhausted)
}

func ToResourceExhausted(parent error, format string, a ...interface{}) error {
return oops.Code(ErrResourceExhausted).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions unauthenticated.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func Unauthenticated(format string, a ...interface{}) error {
return oops.Code(ErrUnauthenticated).Errorf(format, a...)
}

func UnauthenticatedBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrUnauthenticated)
}

func ToUnauthenticated(parent error, format string, a ...interface{}) error {
return oops.Code(ErrUnauthenticated).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions unavailable.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func Unavailable(format string, a ...interface{}) error {
return oops.Code(ErrUnavailable).Errorf(format, a...)
}

func UnavailableBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrUnavailable)
}

func ToUnavailable(parent error, format string, a ...interface{}) error {
return oops.Code(ErrUnavailable).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions unimplemented.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func Unimplemented(format string, a ...interface{}) error {
return oops.Code(ErrUnimplemented).Errorf(format, a...)
}

func UnimplementedBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrUnimplemented)
}

func ToUnimplemented(parent error, format string, a ...interface{}) error {
return oops.Code(ErrUnimplemented).Wrapf(parent, format, a...)
}
Expand Down
4 changes: 4 additions & 0 deletions unknown.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func Unknown(format string, a ...interface{}) error {
return oops.Code(ErrUnknown).Errorf(format, a...)
}

func UnknownBuilder() oops.OopsErrorBuilder {
return oops.Code(ErrUnknown)
}

func ToUnknown(parent error, format string, a ...interface{}) error {
return oops.Code(ErrUnknown).Wrapf(parent, format, a...)
}
Expand Down

0 comments on commit d7942cc

Please sign in to comment.