22 lines
347 B
Go
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)
|
||
|
}
|