mirror of
https://github.com/filecoin-project/lotus.git
synced 2025-08-14 17:50:33 +08:00
feat: support typed errors over RPC
This commit is contained in:
29
api/api_errors.go
Normal file
29
api/api_errors.go
Normal file
@ -0,0 +1,29 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-jsonrpc"
|
||||
)
|
||||
|
||||
const (
|
||||
EOutOfGas = iota + jsonrpc.FirstUserCode
|
||||
EActorNotFound
|
||||
)
|
||||
|
||||
type ErrOutOfGas struct{}
|
||||
|
||||
func (e ErrOutOfGas) Error() string {
|
||||
return "call ran out of gas"
|
||||
}
|
||||
|
||||
type ErrActorNotFound struct{}
|
||||
|
||||
func (e ErrActorNotFound) Error() string {
|
||||
return "actor not found"
|
||||
}
|
||||
|
||||
var RPCErrors = jsonrpc.NewErrors()
|
||||
|
||||
func init() {
|
||||
RPCErrors.Register(EOutOfGas, new(ErrOutOfGas))
|
||||
RPCErrors.Register(EActorNotFound, new(ErrActorNotFound))
|
||||
}
|
Reference in New Issue
Block a user