error.go 567 B

123456789101112131415161718192021222324
  1. package plugin
  2. // This is a type that wraps error types so that they can be messaged
  3. // across RPC channels. Since "error" is an interface, we can't always
  4. // gob-encode the underlying structure. This is a valid error interface
  5. // implementer that we will push across.
  6. type BasicError struct {
  7. Message string
  8. }
  9. // NewBasicError is used to create a BasicError.
  10. //
  11. // err is allowed to be nil.
  12. func NewBasicError(err error) *BasicError {
  13. if err == nil {
  14. return nil
  15. }
  16. return &BasicError{err.Error()}
  17. }
  18. func (e *BasicError) Error() string {
  19. return e.Message
  20. }