33 lines
702 B
Go
33 lines
702 B
Go
|
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))
|
||
|
}
|