mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-03-01 01:20:49 +03:00
30 lines
481 B
Go
30 lines
481 B
Go
package common
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"x-ui/logger"
|
|
)
|
|
|
|
var CtxDone = errors.New("context done")
|
|
|
|
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
|
|
}
|