carbon/errors.go

47 lines
1.7 KiB
Go
Executable File

package carbon
import (
"errors"
"fmt"
)
// 无效的时区错误
var invalidTimezoneError = func(timezone string) error {
return errors.New(fmt.Sprintf("invalid timezone %q, please see the file %q for all valid timezones", timezone, "$GOROOT/lib/time/zoneinfo.zip"))
}
// 无效的持续时长错误
var invalidDurationError = func(duration string) error {
return errors.New(fmt.Sprintf("invalid duration %q, please make sure the duration is valid", duration))
}
// 无效的时间字符串错误
var invalidValueError = func(value string) error {
return errors.New(fmt.Sprintf("cannot parse %q to carbon, please make sure the value is valid", value))
}
// 无效的布局模板错误
var invalidLayoutError = func(value, layout string) error {
return errors.New(fmt.Sprintf("cannot parse %q as layout %q to carbon, please make sure the value and layout match", value, layout))
}
// 无效的格式化字符错误
var invalidFormatError = func(value, format string) error {
return errors.New(fmt.Sprintf("cannot parse %q as format %q to carbon, please make sure the value and format match", value, format))
}
// 无效的区域错误
var invalidLocaleError = func(locale, directory string) error {
return errors.New(fmt.Sprintf("invalid locale %q, please see the directory %q for all valid locales", locale, directory))
}
// 无效的目录错误
var invalidDirError = func(dir string) error {
return errors.New(fmt.Sprintf("invalid directory %q, please make sure the directory exists", dir))
}
// 无效的json文件错误
var invalidJsonFileError = func(file string) error {
return errors.New(fmt.Sprintf("invalid json file %q, please make sure the json file is valid", file))
}