rpc: add HTTPError type for HTTP error responses (#22677)

The new error type is returned by client operations contains details of
the response error code and response body.

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
ryanc414
2021-04-21 14:51:30 +01:00
committed by GitHub
parent 67da83aca5
commit 9357280fce
4 changed files with 81 additions and 23 deletions

View File

@ -35,18 +35,6 @@ type API struct {
Public bool // indication if the methods must be considered safe for public use
}
// Error wraps RPC errors, which contain an error code in addition to the message.
type Error interface {
Error() string // returns the message
ErrorCode() int // returns the code
}
// A DataError contains some data in addition to the error message.
type DataError interface {
Error() string // returns the message
ErrorData() interface{} // returns the error data
}
// ServerCodec implements reading, parsing and writing RPC messages for the server side of
// a RPC session. Implementations must be go-routine safe since the codec can be called in
// multiple go-routines concurrently.