encode/errors.go   A
last analyzed

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
cc 4
eloc 21
dl 0
loc 36
ccs 0
cts 6
cp 0
crap 20
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A encode.*UnsupportedTypeError.Error 0 2 1
A encode.*MarshalerError.Unwrap 0 1 1
A encode.*MarshalerError.Error 0 8 2
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