mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Move from fmt.Errorf to errors.New
In many cases fmt.Errorf is good enough, but since error is an interface, you can use arbitrary data structures as error values, to allow callers to inspect the details of the error.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -34,7 +35,7 @@ func parseDate(str string) (d Date, err error) {
|
||||
y, m, n int
|
||||
)
|
||||
if len(str) != 10 || str[4] != '-' || str[7] != '-' {
|
||||
err = fmt.Errorf("Invalid 0000-00-000 style DATE string: " + str)
|
||||
err = errors.New("Invalid 0000-00-000 style DATE string: " + str)
|
||||
return
|
||||
}
|
||||
if y, err = strconv.Atoi(str[0:4]); err != nil {
|
||||
@@ -44,14 +45,14 @@ func parseDate(str string) (d Date, err error) {
|
||||
return
|
||||
}
|
||||
if m < 1 || m > 12 {
|
||||
err = fmt.Errorf("Invalid 0000-00-000 style DATE string: " + str)
|
||||
err = errors.New("Invalid 0000-00-000 style DATE string: " + str)
|
||||
return
|
||||
}
|
||||
if n, err = strconv.Atoi(str[8:10]); err != nil {
|
||||
return
|
||||
}
|
||||
if n < 1 || n > 31 {
|
||||
err = fmt.Errorf("Invalid 0000-00-000 style DATE string: " + str)
|
||||
err = errors.New("Invalid 0000-00-000 style DATE string: " + str)
|
||||
return
|
||||
}
|
||||
d.Year = int16(y)
|
||||
|
||||
Reference in New Issue
Block a user