electricity_bill_calc_service/exceptions/auth.go

36 lines
645 B
Go

package exceptions
import "fmt"
type AuthenticationError struct {
Code int16
Message string
NeedReset bool
}
func NewAuthenticationError(code int16, msg string) *AuthenticationError {
return &AuthenticationError{
Code: code,
Message: msg,
NeedReset: false,
}
}
func (e AuthenticationError) Error() string {
return fmt.Sprintf("[%d]%s", e.Code, e.Message)
}
type UnauthorizedError struct {
Message string
}
func NewUnauthorizedError(msg string) *UnauthorizedError {
return &UnauthorizedError{
Message: msg,
}
}
func (e UnauthorizedError) Error() string {
return fmt.Sprintf("Unauthorized: %s", e.Message)
}