mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-14 05:23:09 +00:00
* [refactor] api controller * [update] use status code for jsonMsg and 401 to unauthorize * [update] handle response status code via axios * [lint] all .go files
29 lines
440 B
Go
29 lines
440 B
Go
package common
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"x-ui/logger"
|
|
)
|
|
|
|
func NewErrorf(format string, a ...interface{}) error {
|
|
msg := fmt.Sprintf(format, a...)
|
|
return errors.New(msg)
|
|
}
|
|
|
|
func NewError(a ...interface{}) error {
|
|
msg := fmt.Sprintln(a...)
|
|
return errors.New(msg)
|
|
}
|
|
|
|
func Recover(msg string) interface{} {
|
|
panicErr := recover()
|
|
if panicErr != nil {
|
|
if msg != "" {
|
|
logger.Error(msg, "panic:", panicErr)
|
|
}
|
|
}
|
|
return panicErr
|
|
}
|