Skip to content

Commit 4e33c9f

Browse files
author
Aryan Tikarya
committed
remove the error with code interface
1 parent 4358258 commit 4e33c9f

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

errors.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ type marshalable interface {
5959
json.Unmarshaler
6060
}
6161

62-
// ErrorWithCode wraps RPC errors, which contain an error code in addition to the message.
63-
type ErrorWithCode interface {
64-
Error() string // returns the message
65-
ErrorCode() int // returns the code
66-
}
67-
6862
// ErrorWithData contains extra data to explain the error
6963
type ErrorWithData interface {
7064
Error() string // returns the message

handler.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,6 @@ func (s *handler) createError(err error) *respError {
365365
}
366366
}
367367

368-
var ec ErrorWithCode
369-
if errors.As(err, &ec) {
370-
out.Code = ErrorCode(ec.ErrorCode())
371-
}
372-
373368
var ed ErrorWithData
374369
if errors.As(err, &ed) {
375370
out.Data = ed.ErrorData()
@@ -529,9 +524,9 @@ func (s *handler) handle(ctx context.Context, req request, w func(func(io.Writer
529524
Message: err.Error(),
530525
}
531526

532-
var de ErrorWithData
533-
if errors.As(err, &de) {
534-
respErr.Data = de.ErrorData()
527+
var ed ErrorWithData
528+
if errors.As(err, &ed) {
529+
respErr.Data = ed.ErrorData()
535530
}
536531

537532
resp.Error = respErr

0 commit comments

Comments
 (0)