github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/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  }