mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-09 10:18:04 +08:00
commands: Added an Error struct for creating marshallable errors
This commit is contained in:
parent
d1595ce34c
commit
95b0dd29f8
@ -7,6 +7,12 @@ const (
|
||||
// TODO: add more types of errors for better error-specific handling
|
||||
)
|
||||
|
||||
// Error is a struct for marshalling errors
|
||||
type Error struct {
|
||||
message string
|
||||
code ErrorType
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
req *Request
|
||||
Error error
|
||||
@ -19,6 +25,10 @@ func (r *Response) SetError(err error, errType ErrorType) {
|
||||
r.ErrorType = errType
|
||||
}
|
||||
|
||||
func (r *Response) FormatError() Error {
|
||||
return Error{ r.Error.Error(), r.ErrorType }
|
||||
}
|
||||
|
||||
/*func (r *Response) Encode() ([]byte, error) {
|
||||
|
||||
}*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user