diff options
author | xuri <xuri.me@gmail.com> | 2021-12-07 00:26:53 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-12-07 00:26:53 +0800 |
commit | 44a13aa402b0189b119635d2f0a26961795c6bda (patch) | |
tree | 0000ed94fe92507517281812ba49d85aa58a7211 /sparkline.go | |
parent | 3325c3946d0ab77083555bab334381a1167ee580 (diff) |
Export 7 errors so users can act differently on different type of errors
Diffstat (limited to 'sparkline.go')
-rw-r--r-- | sparkline.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sparkline.go b/sparkline.go index 917383d..0d5ef6e 100644 --- a/sparkline.go +++ b/sparkline.go @@ -13,7 +13,6 @@ package excelize import ( "encoding/xml" - "errors" "io" "strings" ) @@ -410,7 +409,7 @@ func (f *File) AddSparkline(sheet string, opt *SparklineOption) (err error) { sparkTypes = map[string]string{"line": "line", "column": "column", "win_loss": "stacked"} if opt.Type != "" { if specifiedSparkTypes, ok = sparkTypes[opt.Type]; !ok { - err = errors.New("parameter 'Type' must be 'line', 'column' or 'win_loss'") + err = ErrSparklineType return } sparkType = specifiedSparkTypes @@ -470,17 +469,17 @@ func (f *File) parseFormatAddSparklineSet(sheet string, opt *SparklineOption) (* return ws, ErrParameterRequired } if len(opt.Location) < 1 { - return ws, errors.New("parameter 'Location' is required") + return ws, ErrSparklineLocation } if len(opt.Range) < 1 { - return ws, errors.New("parameter 'Range' is required") + return ws, ErrSparklineRange } // The ranges and locations must match.\ if len(opt.Location) != len(opt.Range) { - return ws, errors.New(`must have the same number of 'Location' and 'Range' parameters`) + return ws, ErrSparkline } if opt.Style < 0 || opt.Style > 35 { - return ws, errors.New("parameter 'Style' must betweent 0-35") + return ws, ErrSparklineStyle } if ws.ExtLst == nil { ws.ExtLst = &xlsxExtLst{} |