github.com/hashicorp/go-plugin@v1.6.0/error.go (about)

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