errcode
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package errcode
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// header error code ,start:100
|
||||
@@ -88,14 +89,14 @@ var (
|
||||
)
|
||||
|
||||
func NewError(code int, msg string) error {
|
||||
return fiber.NewError(code, msg)
|
||||
return status.New(codes.Code(code), msg).Err()
|
||||
}
|
||||
|
||||
// custom error,status code:500
|
||||
func ErrFatal(msg string) error {
|
||||
return fiber.NewError(500, msg)
|
||||
func ErrFatal(code int, msg string) error {
|
||||
return status.New(codes.Code(code), msg).Err()
|
||||
}
|
||||
|
||||
func ErrNotFound(msg string) error {
|
||||
return fiber.NewError(404, msg+" Not Found")
|
||||
func ErrNotFound(code int, msg string) error {
|
||||
return status.New(codes.Code(code), msg).Err()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user