From 4e33c9f29a6ae6254ba6b5aeb1d33b8ad129e1cd Mon Sep 17 00:00:00 2001 From: Aryan Tikarya Date: Wed, 16 Oct 2024 18:32:29 +0530 Subject: [PATCH] remove the error with code interface --- errors.go | 6 ------ handler.go | 11 +++-------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/errors.go b/errors.go index 19238c5..b720eb2 100644 --- a/errors.go +++ b/errors.go @@ -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 diff --git a/handler.go b/handler.go index f2d6941..ea018b5 100644 --- a/handler.go +++ b/handler.go @@ -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() @@ -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