Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Error code related with request value // ErrValueCannotEmptyOrNil error if value send by client is empty or null ErrValueCannotEmptyOrNil = "10000" // ErrValueNotValidUUID error if value send by client is not valid UUID ErrValueNotValidUUID = "10001" // ErrDatabaseUnavailable error if database is unavailable ErrDatabaseUnavailable = "30000" // ErrDatabaseDataNotFound error if data requested by user or client not found ErrDatabaseDataNotFound = "30001" // ErrDatabaseDuplicate error if data inserted by user or client is duplicate with existing data ErrDatabaseDuplicate = "30002" // ErrDatabaseDataExpectation error if result data from database doesn't meet the expectation ErrDatabaseDataExpectation = "30003" // Error code related with HTTP request ErrInvalidValue = "40400" // ErrUnauthorized error if client unauthenticated ErrPaymentRequired = "40402" // ErrForbidden error if the client does not have access rights to the content ErrForbidden = "40403" // ErrEndpointNotFound error if endpoint is not found ErrEndpointNotFound = "40404" // ErrMethodNotAllowed error if http method not match ErrMethodNotAllowed = "40405" // ErrRequestNotAcceptable error if http header not acceptable ErrRequestNotAcceptable = "40406" ErrProxyAuthRequired = "40407" ErrRequestTimeout = "40408" ErrConflict = "40409" ErrDataMissing = "40410" ErrLengthRequired = "40411" ErrPrecondition = "40412" ErrDataToLarge = "40413" ErrURITooLong = "40414" // ErrUnsupportedMediaType error if http request unsupported media type ErrUnsupportedMediaType = "40415" ErrRangeTooLong = "40416" ErrExpectation = "40417" ErrMisdirectedRequest = "40421" ErrUnprocessableEntity = "40422" ErrDataLocked = "40423" ErrFailedDependency = "40424" ErrTooEarly = "40425" ErrUpgradeRequired = "40426" ErrPreconditionRequired = "40428" ErrTooManyRequests = "40429" ErrHeaderTooLarge = "40431" // ErrInternalServer error if server error or panic, cannot process the request ErrInternalServer = "40500" ErrNotImplemented = "40501" ErrBadGateway = "40502" ErrGateway = "40504" ErrNotSupported = "40505" ErrVariant = "40506" ErrInsufficientStorage = "40507" ErrLoop = "40508" ErrNotExtended = "40510" ErrNetworkAuthentication = "40511" // ErrUnknown if error happen with unknown mapping error ErrUnknown = "99999" )
View Source
const ( // Error message related with request value // ErrValueCannotEmptyOrNilM error if value send by client is empty or null ErrValueCannotEmptyOrNilM = "the value cannot empty or null" // ErrValueNotValidUUIDM error if value send by client is not valid UUID ErrValueNotValidUUIDM = "the value is not valid UUID" // Error message related with HTTP request // ErrEndpointNotFoundM error if endpoint requested by client or user not found ErrEndpointNotFoundM = "the requested endpoint doesn't exists" // ErrMethodNotAllowedCode error if HTTP method not match ErrMethodNotAllowedM = "the http method doesn't match with existing" // ErrRequestNotAcceptableM error if HTTP request header not acceptable ErrRequestNotAcceptableM = "the http header not acceptable" // ErrUnsupportedMediaTypeM error if HTTP request header with unsupported media type ErrUnsupportedMediaTypeM = "unsupported media type" ErrUnauthorizedM = "unauthenticated, check your credentials" // ErrForbiddenM error if the client does not have access rights to the content ErrForbiddenM = "does not have access rights to the content" // ErrDatabaseUnavailableM ErrDatabaseUnavailableM = "the database connection is failed or unavailable" // ErrDatabaseDataNotFoundM error if data requested by client or user not found in database ErrDatabaseDataNotFoundM = "the requested data not found" // ErrDatabaseDuplicateDataM error if data inserted by client or user is duplicate with existing data ErrDatabaseDuplicateDataM = "the data has conflict with existing data" // ErrDatabaseDataExpectationM error if result data from database doesn't meet the expected result ErrDatabaseDataExpectationM = "the data requested doesn't meet the expected result" // ErrInternalServerM error message if internal server error or panic cannot handle request ErrInternalServerM = "server failed process the request because internal issue, server will recover soon" // ErrUnknownM if error happen with unknown error code ErrUnknownM = "unknown error occur. try again later" )
Variables ¶
This section is empty.
Functions ¶
func HTTPStatusCode ¶
func HTTPStatusCode(code interface{}) int
Types ¶
type FailedMessage ¶
type FailedMessage struct {
Code interface{} `json:"code"`
Title string `json:"title"`
Message interface{} `json:"message"`
}
FailedMessage format with title, message, and Code
func FailedEndpointNotFound ¶
func FailedEndpointNotFound() FailedMessage
FailedEndpointNotFound is failed message if client request to endpoint not exist
func FailedForbidden ¶
func FailedForbidden() FailedMessage
FailedForbidden is failed message if the client does not have access rights to the content
func FailedMethodNotAllowed ¶
func FailedMethodNotAllowed() FailedMessage
FailedMethodNotAllowed is failed message if client request with not allowed method
func FailedRequestNotAcceptable ¶
func FailedRequestNotAcceptable() FailedMessage
FailedRequestNotAcceptable is failed message if client http header not acceptable
func FailedUnauthorized ¶
func FailedUnauthorized() FailedMessage
FailedUnauthorized is failed message if client is unauthenticated
func FailedUnsupportedMediaType ¶
func FailedUnsupportedMediaType() FailedMessage
FailedUnsupportedMediaType is failed message if client request with unsupported media type
Click to show internal directories.
Click to hide internal directories.