go17/book/exception/exception.go
2024-11-23 16:08:17 +08:00

22 lines
347 B
Go

package exception
import (
"fmt"
)
func NewApiExceptin(code int, message string) *ApiExceptin {
return &ApiExceptin{
Code: code,
Message: message,
}
}
type ApiExceptin struct {
Code int `json:"code"`
Message string `json:"message"`
}
func (e *ApiExceptin) Error() string {
return fmt.Sprintf("[%d] %s", e.Code, e.Message)
}