go-scn/err.go

33 lines
702 B
Go
Raw Normal View History

2025-01-15 09:02:44 +01:00
package scn
import (
"errors"
"fmt"
)
type ErrorType string
var (
ErrAuthFailed ErrorType = "GOEXT_SCN_AUTHFAILED"
ErrQuota ErrorType = "GOEXT_SCN_QUOTAEXCEEDED"
ErrBadRequest ErrorType = "GOEXT_SCN_BADREQUEST"
ErrInternalServerErr ErrorType = "GOEXT_SCN_INTERNALSERVER"
ErrOther ErrorType = "GOEXT_SCN_OTHER"
)
type InternalError struct {
errType ErrorType
errorMessage string
}
func NewError(errType ErrorType, errMessage string) *InternalError {
return &InternalError{
errType: errType,
errorMessage: errMessage,
}
}
func (e *InternalError) Build() error {
return errors.New(fmt.Sprintf("[%v]: %v", e.errType, e.errorMessage))
}