github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/rpc/error.go (about) 1 package rpc 2 3 // This is a type that wraps error types so that they can be messaged 4 // across RPC channels. Since "error" is an interface, we can't always 5 // gob-encode the underlying structure. This is a valid error interface 6 // implementer that we will push across. 7 type BasicError struct { 8 Message string 9 } 10 11 func NewBasicError(err error) *BasicError { 12 if err == nil { 13 return nil 14 } 15 16 return &BasicError{err.Error()} 17 } 18 19 func (e *BasicError) Error() string { 20 return e.Message 21 } 22 23 // ErrorResponse is a basic response structure that can be used with 24 // the RPC layer to only return an error. 25 type ErrorResponse struct { 26 Error *BasicError 27 }