Skip to content

Commit

Permalink
remove the error with code interface
Browse files Browse the repository at this point in the history
  • Loading branch information
akaladarshi committed Oct 16, 2024
1 parent 4358258 commit 4e33c9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
6 changes: 0 additions & 6 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ type marshalable interface {
json.Unmarshaler
}

// ErrorWithCode wraps RPC errors, which contain an error code in addition to the message.
type ErrorWithCode interface {
Error() string // returns the message
ErrorCode() int // returns the code
}

// ErrorWithData contains extra data to explain the error
type ErrorWithData interface {
Error() string // returns the message
Expand Down
11 changes: 3 additions & 8 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,6 @@ func (s *handler) createError(err error) *respError {
}
}

var ec ErrorWithCode
if errors.As(err, &ec) {
out.Code = ErrorCode(ec.ErrorCode())
}

var ed ErrorWithData
if errors.As(err, &ed) {
out.Data = ed.ErrorData()
Expand Down Expand Up @@ -529,9 +524,9 @@ func (s *handler) handle(ctx context.Context, req request, w func(func(io.Writer
Message: err.Error(),
}

var de ErrorWithData
if errors.As(err, &de) {
respErr.Data = de.ErrorData()
var ed ErrorWithData
if errors.As(err, &ed) {
respErr.Data = ed.ErrorData()
}

resp.Error = respErr
Expand Down

0 comments on commit 4e33c9f

Please sign in to comment.