forked from menduo/exsoul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
33 lines (27 loc) · 937 Bytes
/
errors.go
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
// Created by @menduo @ 2020/7/14
package exsoul
import (
"errors"
"fmt"
)
var (
ErrorOutOfRange = errors.New("[ExSoul] Out of range")
ErrorInvalidInput = errors.New("[ExSoul] Invalid Input")
ErrorParam = errors.New("[ExSoul] Invalid Param")
)
func newInvalidInputError(format string, values ...interface{}) error {
format = fmt.Sprintf("%s: %s", ErrorInvalidInput, format)
return errors.New(fmt.Sprintf(format, values...))
}
func newParamError(format string, values ...interface{}) error {
format = fmt.Sprintf("%s: %s", ErrorParam, format)
return errors.New(fmt.Sprintf(format, values...))
}
func newParamErrorWithError(prefix string, err error) error {
msg := fmt.Sprintf("%s: %s %s", ErrorParam, prefix, err.Error())
return errors.New(msg)
}
func newError(format string, values ...interface{}) error {
format = fmt.Sprintf("%s: %s", "[ExSoul]", format)
return errors.New(fmt.Sprintf(format, values...))
}