-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
42 lines (34 loc) · 745 Bytes
/
errors.go
File metadata and controls
42 lines (34 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package excel
import (
"errors"
"fmt"
)
type Error interface {
error
Args(...any) Error
}
type excelError struct {
text string
args []any
}
func (r *excelError) Error() string {
if len(r.args) > 0 {
return fmt.Sprintf(r.text, r.args...)
}
return r.text
}
func (r *excelError) Args(args ...any) Error {
r.args = args
return r
}
func newError(text string) Error {
return &excelError{text: text}
}
var (
ErrInvalidTarget = newError("excel: target must be a pointer to a slice")
ErrTargetMustBeSliceOfStructs = newError("excel: target must be a slice of structs")
ErrNoHeaders = newError("excel: headers not found or empty")
)
func Is(err, target error) bool {
return errors.Is(err, target)
}