Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions rpc/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ func errorMessage(err error) *jsonrpcMessage {
Code: errcodeDefault,
Message: err.Error(),
}}
ec, ok := err.(Error)
if ok {
msg.Error.Code = ec.ErrorCode()
var rpcError Error
if errors.As(err, &rpcError) {
msg.Error.Code = rpcError.ErrorCode()
}
de, ok := err.(DataError)
// Type assert on rpcError to ensure that both code and data come from the same error object.
de, ok := rpcError.(DataError)
if ok {
msg.Error.Data = de.ErrorData()
}
Expand Down
Loading