erresponse

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Collection = &Collect{}
View Source
var InvalidClient = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Unauthorized,
	Name:        constant.ErrorInvalidClient,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "401001",
	},
})
View Source
var InvalidClientExpiresAtIsTooLong = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Unauthorized,
	Name:        constant.ErrorInvalidClient,
	Description: "client secret exp is too long",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "401002",
	},
})
View Source
var InvalidGrant = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Forbidden,
	Name:        constant.ErrorInvalidGrant,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "403001",
	},
})
View Source
var InvalidGrantConditionCheckFail = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Forbidden,
	Name:        constant.ErrorInvalidGrant,
	Description: "condition check fail",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "403004",
	},
})
View Source
var InvalidGrantPhoneAlreadySetup = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Forbidden,
	Name:        constant.ErrorInvalidGrant,
	Description: "phone already setup",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "403002",
	},
})
View Source
var InvalidGrantRefreshTokenExpired = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Unauthorized,
	Name:        constant.ErrorInvalidToken,
	Description: "refresh_token is expired",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "401103",
	},
})
View Source
var InvalidGrantScopeNotGranted = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Forbidden,
	Name:        constant.ErrorInsufficientScope,
	Description: "scope not granted",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "403101",
	},
})
View Source
var InvalidGrantUserNotExistOrPasswordNotMatch = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Forbidden,
	Name:        constant.ErrorInvalidGrant,
	Description: "user is not exist or password is not correct",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "403003",
	},
})
View Source
var InvalidRequest = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400001",
	},
})
View Source
var InvalidRequestCantConvert = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "can not convert",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400002",
	},
})
View Source
var InvalidRequestEmailUsed = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "email used",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400003",
	},
})
View Source
var InvalidRequestExpired = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "request expired",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400004",
	},
})
View Source
var InvalidRequestInvalidRequestUri = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "invalid request_uri",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400011",
	},
})
View Source
var InvalidRequestPhoneUsed = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "phone used",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400010",
	},
})
View Source
var InvalidRequestRecentPassword = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "recent password",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400009",
	},
})
View Source
var InvalidRequestRedirectUriIsNotMatch = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "redirect_uri is not match",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400012",
	},
})
View Source
var InvalidRequestSamePassword = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "same password",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400007",
	},
})
View Source
var InvalidRequestWeakPassword = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "weak password",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400008",
	},
})
View Source
var InvalidRequestWrongBodyFormat = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "wrong body format",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400015",
	},
})
View Source
var InvalidRequestWrongCodeChallenge = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "code_challenge format wrong",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400014",
	},
})
View Source
var InvalidRequestWrongCodeChallengeMethod = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "code_challenge_method should be `plain` or `S256`",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400013",
	},
})
View Source
var InvalidRequestWrongPassword = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "wrong password",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400006",
	},
})
View Source
var InvalidRequestWrongTokenFormat = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidRequest,
	Description: "wrong token format",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400005",
	},
})
View Source
var InvalidScope = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorInvalidScope,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400201",
	},
})
View Source
var InvalidToken = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Unauthorized,
	Name:        constant.ErrorInvalidToken,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "401101",
	},
})
View Source
var InvalidTokenExpiredOrRevoked = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Unauthorized,
	Name:        constant.ErrorInvalidToken,
	Description: "token expired or revoked",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "401102",
	},
})
View Source
var MethodNotAllowed = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.MethodNotAllowed,
	Name:        "method_not_allowed",
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "405001",
	},
})
View Source
var NotFound = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.NotFound,
	Name:        constant.ErrorNotFound,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "404001",
	},
})
View Source
var NotFoundCredentialNotFound = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.NotFound,
	Name:        constant.ErrorNotFound,
	Description: "credential not found",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Urgent,
		ErrorCategory: kkerror.Server,
		ErrorCode:     "404004",
	},
})
View Source
var NotFoundObjectNotExist = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.NotFound,
	Name:        constant.ErrorNotFound,
	Description: "target object is not exist",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "404002",
	},
})
View Source
var NotFoundUserNotFound = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.NotFound,
	Name:        constant.ErrorNotFound,
	Description: "user not found",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "404003",
	},
})
View Source
var NotImplemented = Collection.Register(&DefaultErrorResponse{
	StatusCode:  0,
	Name:        constant.ErrorNotImplemented,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Server,
		ErrorCode:     "000000",
		ErrorMessage:  "not_implemented",
	},
})
View Source
var SRPUnsupported = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.Forbidden,
	Name:        constant.ErrorSRPUnsupported,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "403201",
	},
})
View Source
var ServerError = Collection.Register(&DefaultErrorResponse{
	StatusCode: httpstatus.InternalServerError,
	Name:       constant.ErrorServerError,
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Urgent,
		ErrorCategory: kkerror.Server,
		ErrorCode:     "500001",
	},
})
View Source
var ServerErrorCacheOperationFail = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "cache operation fail",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Critical,
		ErrorCategory: kkerror.Cache,
		ErrorCode:     "500006",
	},
})
View Source
var ServerErrorCantGetNecessaryData = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "can't get necessary data",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Urgent,
		ErrorCategory: kkerror.Server,
		ErrorCode:     "500002",
	},
})
View Source
var ServerErrorCrossServiceOperationFail = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "cross service operation fail",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Critical,
		ErrorCategory: kkerror.Internal,
		ErrorCode:     "500009",
	},
})
View Source
var ServerErrorDatabaseOperationFail = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "database operation fail",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Critical,
		ErrorCategory: kkerror.Database,
		ErrorCode:     "500005",
	},
})
View Source
var ServerErrorEmailOperationFail = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "email operation fail",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Urgent,
		ErrorCategory: kkerror.Internal,
		ErrorCode:     "500007",
	},
})
View Source
var ServerErrorOperationCantBeDone = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "operation can't be done",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Critical,
		ErrorCategory: kkerror.Process,
		ErrorCode:     "500003",
	},
})
View Source
var ServerErrorOtherServiceConnectionDefeated = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "other service connection defeated",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Urgent,
		ErrorCategory: kkerror.Internal,
		ErrorCode:     "500004",
	},
})
View Source
var ServerErrorPanic = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "panic",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Urgent,
		ErrorCategory: kkerror.Server,
		ErrorCode:     "500099",
	},
})
View Source
var ServerErrorSMSOperationFail = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.InternalServerError,
	Name:        constant.ErrorServerError,
	Description: "sms operation fail",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Critical,
		ErrorCategory: kkerror.Internal,
		ErrorCode:     "500008",
	},
})
View Source
var SlowDownTooFast = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.TooManyRequests,
	Name:        constant.ErrorSlowDown,
	Description: "too fast, rate limit exceeded",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "429001",
	},
})
View Source
var UnsupportedGrantType = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorUnsupportedGrantType,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400301",
	},
})
View Source
var UnsupportedOperation = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        "unsupported_operation",
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Urgent,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400302",
	},
})
View Source
var UnsupportedResponseType = Collection.Register(&DefaultErrorResponse{
	StatusCode:  httpstatus.BadRequest,
	Name:        constant.ErrorUnsupportedResponseType,
	Description: "",
	DefaultKKError: kkerror.DefaultKKError{
		ErrorLevel:    kkerror.Normal,
		ErrorCategory: kkerror.Client,
		ErrorCode:     "400303",
	},
})

Functions

This section is empty.

Types

type Collect

type Collect struct {
	ErrorResponses map[ErrorResponse]ErrorResponse
	// contains filtered or unexported fields
}

func (*Collect) Register

func (c *Collect) Register(err ErrorResponse) ErrorResponse

type DefaultErrorResponse

type DefaultErrorResponse struct {
	kkerror.DefaultKKError
	StatusCode  int                    `json:"status_code,omitempty"`
	Name        string                 `json:"error,omitempty"`
	Description string                 `json:"error_description,omitempty"`
	Data        map[string]interface{} `json:"data,omitempty"`
}

func (*DefaultErrorResponse) Clone

func (*DefaultErrorResponse) Error

func (d *DefaultErrorResponse) Error() string

func (*DefaultErrorResponse) ErrorData

func (d *DefaultErrorResponse) ErrorData() map[string]interface{}

func (*DefaultErrorResponse) ErrorDescription

func (d *DefaultErrorResponse) ErrorDescription() string

func (*DefaultErrorResponse) ErrorName

func (d *DefaultErrorResponse) ErrorName() string

func (*DefaultErrorResponse) ErrorStatusCode

func (d *DefaultErrorResponse) ErrorStatusCode() int

type ErrorResponse

type ErrorResponse interface {
	kkerror.KKError
	ErrorStatusCode() int
	ErrorName() string
	ErrorDescription() string
	ErrorData() map[string]interface{}
	Clone() ErrorResponse
}

func InvalidRequestCantBeEmptyOfName

func InvalidRequestCantBeEmptyOfName(name string) ErrorResponse

func InvalidRequestInvalidDataOfName

func InvalidRequestInvalidDataOfName(name string) ErrorResponse

func InvalidRequestParameterTooLongOfName

func InvalidRequestParameterTooLongOfName(name string) ErrorResponse

func InvalidRequestWithMessage

func InvalidRequestWithMessage(format string, params ...interface{}) ErrorResponse

func InvalidRequestWrongFormatOfName

func InvalidRequestWrongFormatOfName(name string) ErrorResponse

func NotFoundWithMessage

func NotFoundWithMessage(format string, params ...interface{}) ErrorResponse

func ServerErrorCacheOperationWithMessage

func ServerErrorCacheOperationWithMessage(format string, params ...interface{}) ErrorResponse

func ServerErrorCrossServiceOperationWithMessage

func ServerErrorCrossServiceOperationWithMessage(format string, params ...interface{}) ErrorResponse

func ServerErrorDatabaseOperationWithMessage

func ServerErrorDatabaseOperationWithMessage(format string, params ...interface{}) ErrorResponse

func ServerErrorEmailOperationWithMessage

func ServerErrorEmailOperationWithMessage(format string, params ...interface{}) ErrorResponse

func ServerErrorPanicWithMessage

func ServerErrorPanicWithMessage(format string, params ...interface{}) ErrorResponse

func ServerErrorSMSOperationWithMessage

func ServerErrorSMSOperationWithMessage(format string, params ...interface{}) ErrorResponse

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL