File: error.go

package info (click to toggle)
golang-github-hashicorp-go-plugin 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 592 kB
  • sloc: python: 38; makefile: 7
file content (24 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package plugin

// This is a type that wraps error types so that they can be messaged
// across RPC channels. Since "error" is an interface, we can't always
// gob-encode the underlying structure. This is a valid error interface
// implementer that we will push across.
type BasicError struct {
	Message string
}

// NewBasicError is used to create a BasicError.
//
// err is allowed to be nil.
func NewBasicError(err error) *BasicError {
	if err == nil {
		return nil
	}

	return &BasicError{err.Error()}
}

func (e *BasicError) Error() string {
	return e.Message
}