encode.*MarshalerError.Unwrap   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
dl 0
loc 1
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
nop 0
1
package encode
2
3
import (
4
	"errors"
5
	"reflect"
6
)
7
8
var (
9
	ErrInvalidValue = errors.New("invalid value")
10
)
11
12
type UnsupportedTypeError struct {
13
	Type reflect.Type
14
}
15
16
func (e *UnsupportedTypeError) Error() string {
17
	return "binn: unsupported type: " + e.Type.String()
18
}
19
20
type MarshalerError struct {
21
	Type       reflect.Type
22
	Err        error
23
	sourceFunc string
24
}
25
26
func (e *MarshalerError) Error() string {
27
	srcFunc := e.sourceFunc
28
	if srcFunc == "" {
29
		srcFunc = "MarshalBINN"
30
	}
31
	return "binn: error calling " + srcFunc +
32
		" for type " + e.Type.String() +
33
		": " + e.Err.Error()
34
}
35
36
func (e *MarshalerError) Unwrap() error { return e.Err }
37