mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-15 20:22:09 +08:00
29 lines
380 B
Go
29 lines
380 B
Go
package eerror
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
E "github.com/pkg/errors"
|
|
)
|
|
|
|
func Throw(msg string) {
|
|
throw(msg, nil, 0)
|
|
}
|
|
|
|
func ThrowWrap(msg string, err error) {
|
|
throw(msg, err, 0)
|
|
}
|
|
|
|
func throw(msg string, err error, code int) {
|
|
var errInfo error
|
|
if err != nil {
|
|
errInfo = E.Wrap(err, msg)
|
|
} else {
|
|
errInfo = E.New(msg)
|
|
}
|
|
|
|
fmt.Printf("Error: %+v", errInfo)
|
|
os.Exit(code)
|
|
}
|