Documentation ¶
Index ¶
Constants ¶
const ( // Success 指成功 Success = "200001" // SuccessNoContent 代表成功同時不需要回傳的內容 SuccessNoContent = "204001" // StatusNotModified 代表資源未變更 StatusNotModified = "304001" // BadRequest 代表條件不符合 BadRequest = "400001" // InvalidAuthenticationInfo 代表認證資訊錯誤 InvalidAuthenticationInfo = "400003" // InvalidHeaderValue - The value provided for one of the HTTP headers was not in the correct format.")] InvalidHeaderValue = "400004" // InvalidInput - One of the request inputs is not valid.")] InvalidInput = "400006" // InvalidQueryParameterValue - An invalid value was specified for one of the query parameters in the request URI.")] InvalidQueryParameterValue = "400009" // OrderAmountNotEnabled - Order Amount Not Enabled OrderAmountNotEnabled = "400010" // MissingRequiredHeader - A required HTTP header was not specified. MissingRequiredHeader = "400017" // OutOfRangeInput - One of the request inputs is out of range.")] OutOfRangeInput = "400020" // InvalidAppVersion - Check app version from x-app-version, and the version is invalid InvalidAppVersion = "400030" // AppGeneralError - return specific error struct for APP to show AppGeneralError = "400040" Unauthorized = "401001" // AccountIsDisabled - The specified account is disabled." )] AccountIsDisabled = "403001" // AuthenticationFailed - Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature. AuthenticationFailed = "403002" // NotAllowed - The request is understood, but it has been refused or access is not allowed.")] NotAllowed = "403003" // InsufficientAccountPermissionsWithOperation - The account being accessed does not have sufficient permissions to execute this operation InsufficientAccountPermissionsWithOperation = "403005" // UsernameOrPasswordIncorrect - Username or Password is incorrect UsernameOrPasswordIncorrect = "403006" // OtpRequired - OTP Binding is required. OtpRequired = "403007" // OtpAuthorizationRequired - Two-factor authorization is required OtpAuthorizationRequired = "403008" // OtpIncorrect - OTP is incorrect OtpIncorrect = "403009" // ResetPasswordRequired - Reset Password Required ResetPasswordRequired = "403010" // ResourceNotFound - The specified resource does not exist. ResourceNotFound = "404001" // ResourceDependencyNotFound - The specified resource dependency does not exist ResourceDependencyNotFound = "404002" // OrderNotFound - The specified order not found OrderNotFound = "404003" // SettingNotFound - The specified setting not found SettingNotFound = "404004" // QRCodeNotFound - The specified QRCode not found QRCodeNotFound = "404005" // PaymentAccountNotFound - Payment account not found PaymentAccountNotFound = "404006" // CustomerServiceNotFound - Customer service not found CustomerServiceNotFound = "404007" // OrderTypeNotFound - Order type not found OrderTypeNotFound = "404008" // QRCodeTypeNotFound - QRCode type not found QRCodeTypeNotFound = "404009" // AccountAlreadyExists - The specified account already exists. AccountAlreadyExists = "409001" // ResourceAlreadyExists - Conflict (409) - The specified resource already exists.")] ResourceAlreadyExists = "409004" // InternalError - "Internal Server Error (500) - The server encountered an internal error. Please retry the request. InternalError = "500001" ServiceUnavailable = "503001" )
Variables ¶
var ( // ErrBadRequest = _error{Code: "400000", Message: http.StatusText(http.StatusBadRequest), Status: http.StatusBadRequest} ErrInvalidInput = _error{Code: "400001", Message: "One of the request inputs is not valid.", Status: http.StatusBadRequest} ErrInvalidHeaderValue = _error{Code: "400004", Message: "The value provided for one of the HTTP headers was not in the correct format.", Status: http.StatusBadRequest} ErrMissingRequiredHeader = _error{Code: "400017", Message: "A required HTTP header was not specified.", Status: http.StatusBadRequest} ErrInternalDataNotSync = _error{Code: "400041", Message: "The specified data not sync in system, please wait a moment.", Status: http.StatusBadRequest} ErrInvalidAuthenticationInfo = _error{Code: "401001", Message: "The authentication information was not provided in the correct format. Verify the value of Authorization header.", Status: http.StatusUnauthorized} ErrUsernameOrPasswordIncorrect = _error{Code: "401002", Message: "Username or Password is incorrect.", Status: http.StatusUnauthorized} // ErrForbidden = _error{Code: "403000", Message: http.StatusText(http.StatusForbidden), Status: http.StatusForbidden} ErrAccountIsDisabled = _error{Code: "403001", Message: "The specified account is disabled.", Status: http.StatusForbidden} ErrAuthenticationFailed = _error{Code: "403002", Message: "Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature.", Status: http.StatusForbidden} ErrNotAllowed = _error{Code: "403003", Message: "The request is understood, but it has been refused or access is not allowed.", Status: http.StatusForbidden} ErrOtpExpired = _error{Code: "403004", Message: "OTP is expired.", Status: http.StatusForbidden} ErrInsufficientAccountPermissionsWithOperation = _error{Code: "403005", Message: "The account being accessed does not have sufficient permissions to execute this operation.", Status: http.StatusForbidden} ErrOptRequired = _error{Code: "403007", Message: "OTP Binding is required.", Status: http.StatusForbidden} ErrOtpAuthorizationRequired = _error{Code: "403008", Message: "Two-factor authorization is required.", Status: http.StatusForbidden} ErrOtpIncorrect = _error{Code: "403009", Message: "OTP is incorrect.", Status: http.StatusForbidden} ErrResetPasswordRequired = _error{Code: "403010", Message: "Reset password is required.", Status: http.StatusForbidden} // ErrNotFound = _error{Code: "404000", Message: http.StatusText(http.StatusNotFound), Status: http.StatusNotFound} ErrResourceNotFound = _error{Code: "404001", Message: "The specified resource does not exist.", Status: http.StatusNotFound} ErrConflict = _error{Code: "409000", Message: http.StatusText(http.StatusConflict), Status: http.StatusConflict} ErrAccountAlreadyExists = _error{Code: "409001", Message: "The specified account already exists.", Status: http.StatusConflict} ErrAccountBeingCreated = _error{Code: "409002", Message: "The specified account is in the process of being created.", Status: http.StatusConflict} ErrResourceAlreadyExists = _error{Code: "409004", Message: "The specified resource already exists.", Status: http.StatusConflict} ErrInternalServerError = _error{Code: "500000", Message: http.StatusText(http.StatusInternalServerError), Status: http.StatusInternalServerError} ErrInternalError = _error{Code: "500001", Message: "The server encountered an internal error. Please retry the request.", Status: http.StatusInternalServerError} )
自定義的 errors, 我還要定義更多 error \(ˋ皿ˊ)/ <---怪叔叔 ಠ_ಠ
var Cause = errors.Cause
Cause is as the proxy for github.com/pkg/errors.Cause func.
func Cause(err error) error { return errors.Cause(err) }
var Errorf = errors.Errorf
Errorf is as the proxy for github.com/pkg/errors.Errorf func.
func Errorf(format string, args ...interface{}) error { return errors.Errorf(format, args...) }
var PkgNew = errors.New
PkgNew is as the proxy for github.com/pkg/errors.New func.
func New(message string) error { return errors.New(message) }
var WithMessage = errors.WithMessage
WithMessage is as the proxy for github.com/pkg/errors.WithMessage func.
func WithMessage(err error, message string) error { return errors.WithMessage(err, message) }
var WithMessagef = errors.WithMessagef
WithMessagef is as the proxy for github.com/pkg/errors.WithMessagef func.
func WithMessagef(err error, format string, args ...interface{}) error { return errors.WithMessagef(err, format, args...) }
var WithStack = errors.WithStack
WithStack is as the proxy for github.com/pkg/errors.WithStack func.
func WithStack(err error) error { return errors.WithStack(err) }
var Wrap = errors.Wrap
Wrap is as the proxy for github.com/pkg/errors.Wrap func.
func Wrap(err error, message string) error { return errors.Wrap(err, message) }
var Wrapf = errors.Wrapf
Wrapf is as the proxy for github.com/pkg/errors.Wrapf func.
func Wrapf(err error, format string, args ...interface{}) error { return errors.Wrapf(err, format, args...) }
Functions ¶
func HTTPErrorHandlerForEcho ¶
HTTPErrorHandlerForEcho responds error response according to given error.
func NewWithMessage ¶
NewWithMessage 抽換錯誤訊息 未定義的錯誤會被視為 ErrInternalError 類型
func NotFoundHandlerForEcho ¶
NotFoundHandlerForEcho responds not found response.
Types ¶
This section is empty.