-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
36 lines (30 loc) · 837 Bytes
/
Copy patherrors.go
File metadata and controls
36 lines (30 loc) · 837 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
package main
import (
"encoding/csv"
"errors"
"fmt"
)
var ErrProcessEaryBail = errors.New("error, processing needed to be finished due to context cancellation")
var ErrInvalidField = errors.New("error, can not parse the field")
var ErrInvalidFieldsCount = errors.New("error, can not parse the row, invalid fields count")
type FieldParseError struct {
err error
fieldName string
}
func (pe FieldParseError) Error() string {
if pe.fieldName != "" {
return fmt.Sprintf("error when parsing field %s %v", pe.fieldName, pe.err)
}
return pe.err.Error()
}
func (pe FieldParseError) IsRetryable() bool {
if errors.Is(pe.err, ErrInvalidField) ||
errors.Is(pe.err, ErrInvalidFieldsCount) ||
errors.Is(pe.err, csv.ErrFieldCount) {
return true
}
return false
}
func (e FieldParseError) Unwrap() error {
return e.err
}