Skip to content

Commit 4358258

Browse files
author
Aryan Tikarya
committed
address comments
1 parent 53eab64 commit 4358258

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

errors.go

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

62-
// Error wraps RPC errors, which contain an error code in addition to the message.
63-
type Error interface {
62+
// ErrorWithCode wraps RPC errors, which contain an error code in addition to the message.
63+
type ErrorWithCode interface {
6464
Error() string // returns the message
6565
ErrorCode() int // returns the code
6666
}
6767

68-
// DataError contains extra data to explain the error
69-
type DataError interface {
68+
// ErrorWithData contains extra data to explain the error
69+
type ErrorWithData interface {
7070
Error() string // returns the message
7171
ErrorData() interface{} // returns the error data
7272
}

handler.go

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

368-
var err2 Error
369-
if errors.As(err, &err2) {
370-
out.Code = ErrorCode(err2.ErrorCode())
368+
var ec ErrorWithCode
369+
if errors.As(err, &ec) {
370+
out.Code = ErrorCode(ec.ErrorCode())
371371
}
372372

373-
var de DataError
374-
if errors.As(err, &de) {
375-
out.Data = de.ErrorData()
373+
var ed ErrorWithData
374+
if errors.As(err, &ed) {
375+
out.Data = ed.ErrorData()
376376
}
377377

378378
return out
@@ -529,7 +529,7 @@ func (s *handler) handle(ctx context.Context, req request, w func(func(io.Writer
529529
Message: err.Error(),
530530
}
531531

532-
var de DataError
532+
var de ErrorWithData
533533
if errors.As(err, &de) {
534534
respErr.Data = de.ErrorData()
535535
}

0 commit comments

Comments
 (0)