-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
60 lines (53 loc) · 2.56 KB
/
Copy patherrors.go
File metadata and controls
60 lines (53 loc) · 2.56 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package goods
import (
"errors"
"fmt"
)
// Sentinel errors returned by the package. Callers may compare with errors.Is.
var (
ErrSheetNotFound = errors.New("goods: sheet not found")
ErrSheetExists = errors.New("goods: sheet already exists")
ErrSheetNameEmpty = errors.New("goods: sheet name cannot be empty")
ErrNoSheets = errors.New("goods: workbook must have at least one sheet")
ErrInvalidCell = errors.New("goods: invalid cell reference")
ErrInvalidCoords = errors.New("goods: invalid coordinates")
ErrColumnOutOfRange = errors.New("goods: column number out of range")
ErrRowOutOfRange = errors.New("goods: row number out of range")
ErrMergeOverlap = errors.New("goods: merge range overlaps with existing merge")
ErrMergeNotFound = errors.New("goods: merge range not found")
ErrStyleNotFound = errors.New("goods: style not found")
ErrFileClosed = errors.New("goods: file is closed")
ErrInvalidODS = errors.New("goods: invalid ODS file")
ErrUnsupportedType = errors.New("goods: unsupported value type")
ErrCircularReference = errors.New("goods: circular reference detected")
ErrNamedRangeNotFound = errors.New("goods: named range not found")
ErrNamedRangeExists = errors.New("goods: named range already exists")
ErrValidationNotFound = errors.New("goods: data validation not found")
ErrAutoFilterExists = errors.New("goods: auto-filter already exists on this sheet")
ErrAutoFilterNotFound = errors.New("goods: auto-filter not found")
ErrConditionalFormatNotFound = errors.New("goods: conditional format not found")
)
// CellError wraps an underlying error with the sheet name and cell reference
// where the failure occurred. The wrapped error is accessible via errors.Unwrap.
type CellError struct {
Sheet string
Cell string
Err error
}
// Error returns the error message including the sheet and, when available, the cell reference.
func (e *CellError) Error() string {
if e.Cell != "" {
return fmt.Sprintf("sheet %q cell %s: %v", e.Sheet, e.Cell, e.Err)
}
return fmt.Sprintf("sheet %q: %v", e.Sheet, e.Err)
}
// Unwrap returns the underlying error for use with errors.Is and errors.As.
func (e *CellError) Unwrap() error {
return e.Err
}
func sheetErr(sheet string, err error) *CellError {
return &CellError{Sheet: sheet, Err: err}
}
func cellErr(sheet, cell string, err error) *CellError {
return &CellError{Sheet: sheet, Cell: cell, Err: err}
}