github.com/leowmjw/otto@v0.2.1-0.20160126165905-6400716cf085/otto/error.go (about)

     1  package otto
     2  
     3  // Error is the interface implemented by many errors within Otto. You
     4  // can use it to check what the type of an error is via the list of
     5  // error codes below.
     6  type Error interface {
     7  	OriginalError() error
     8  	Code() string
     9  }
    10  
    11  // codedError is the type used internally that implements the Error interface
    12  type codedError struct {
    13  	err  error
    14  	code string
    15  }
    16  
    17  func (e *codedError) Error() string        { return e.err.Error() }
    18  func (e *codedError) OriginalError() error { return e.err }
    19  func (e *codedError) Code() string         { return e.code }
    20  
    21  // errwrap.Wrapper impl.
    22  func (e *codedError) WrappedErrors() []error { return []error{e.OriginalError()} }