Documentation ¶
Index ¶
- Constants
- Variables
- type Error
- func BadRequestError(message string) *Error
- func BadRequestErrorf(format string, a ...any) *Error
- func ConflictError(message string) *Error
- func ConflictErrorf(format string, a ...any) *Error
- func ForbiddenError(message string) *Error
- func ForbiddenErrorf(format string, a ...any) *Error
- func InternalServerError(message string) *Error
- func InternalServerErrorf(format string, a ...any) *Error
- func New(code string, status int, message string) *Error
- func Newf(code string, status int, format string, a ...any) *Error
- func NotFoundError(message string) *Error
- func NotFoundErrorf(format string, a ...any) *Error
- func UnauthorizedError(message string) *Error
- func UnauthorizedErrorf(format string, a ...any) *Error
- type Errors
Constants ¶
const ( ErrCodeBadRequest = "BAD_REQUEST" ErrCodeInsufficientAccess = "INSUFFICIENT_ACCESS" ErrCodeNotFound = "NOT_FOUND" ErrCodePathNotFound = "PATH_NOT_FOUND" ErrCodeMethodNotAllowed = "METHOD_NOT_ALLOWED" ErrCodeConflict = "CONFLICT" ErrCodeInternalServerError = "INTERNAL_SERVER_ERROR" ErrCodeNotImplementedError = "NOT_IMPLEMENTED" ErrCodeMissingMandatoryParameter = "MISSING_MANDATORY_PARAMETER" ErrCodeMissingMandatoryConfiguration = "MISSING_MANDATORY_CONFIGURATION" ErrCodeConfigLoad = "CONFIG_LOAD_ERROR" ErrCodeServerStartupFailed = "SERVER_STARTUP_FAILED" ErrCodeInvalidServerProtocol = "SERVER_PROTOCOL_INVALID" ErrCodeInvalidServerLogLevel = "SERVER_LOG_LEVEL_INVALID" ErrCodeInvalidPassword = "PASSWORD_INVALID" ErrCodePasswordEncryptionError = "PASSWORD_ENCRYPTION_FAILED" ErrCodePasswordDecryptionError = "PASSWORD_DECRYPTION_FAILED" ErrCodeRegexCompileError = "REGEX_COMPILE_ERROR" ErrCodeJSONMarshalError = "JSON_MARSHAL_ERROR" ErrCodeJSONUnmarshalError = "JSON_UNMARSHAL_ERROR" ErrCodeYAMLMarshalError = "YAML_MARSHAL_ERROR" ErrCodeYAMLUnmarshalError = "YAML_UNMARSHAL_ERROR" ErrCodeBase64DecodeError = "BASE64_DECODE_ERROR" ErrCodeFileNotFound = "FILE_NOT_FOUND" ErrCodeFileCreateError = "FILE_CREATE_ERROR" ErrCodeFileRemoveError = "FILE_REMOVE_ERROR" ErrCodeFileOpenError = "FILE_OPEN_ERROR" ErrCodeFileReadError = "FILE_READ_ERROR" ErrCodeFileWriteError = "FILE_WRITE_ERROR" ErrCodeBasicAuthMissing = "BASIC_AUTH_MISSING" ErrCodeInvalidCredentials = "CREDENTIALS_INVALID" ErrCodeInvalidPayload = "PAYLOAD_INVALID" ErrCodeTraceIdMissing = "TRACE_ID_MISSING" ErrCodeSubjectTokenTypeMissing = "SUBJECT_TOKEN_TYPE_MISSING" ErrCodeSubjectTokenMissing = "SUBJECT_TOKEN_MISSING" ErrCodeSubjectTokenTypeInvalid = "SUBJECT_TOKEN_TYPE_INVALID" ErrCodeSubjectUnauthenticated = "SUBJECT_UNAUTHENTICATED" ErrCodeSubjectNotAllowed = "SUBJECT_NOT_ALLOWED" )
Variables ¶
var ( ErrMsg = map[string]string{ ErrCodeBadRequest: http.StatusText(http.StatusBadRequest), ErrCodeUnauthorized: http.StatusText(http.StatusUnauthorized), ErrCodeInsufficientAccess: "Insufficient access", ErrCodeNotFound: http.StatusText(http.StatusNotFound), ErrCodePathNotFound: "Path Not Found", ErrCodeMethodNotAllowed: http.StatusText(http.StatusMethodNotAllowed), ErrCodeConflict: http.StatusText(http.StatusConflict), ErrCodeInternalServerError: "Unable to process the request due to an internal error. Please contact the system administrator", ErrCodeNotImplementedError: "Not Implemented", ErrCodeMissingMandatoryParameter: "Missing mandatory parameters : %v", ErrCodeMissingMandatoryConfiguration: "Missing mandatory configuration : %v", ErrCodeConfigLoad: "Error loading configuration: %s", ErrCodeServerStartupFailed: "Server startup failed: %v", ErrCodeInvalidServerProtocol: "Invalid server protocol '%s'", ErrCodeInvalidServerLogLevel: "Invalid server log Level '%s'", ErrCodeInvalidPassword: "Password should be at least 8 characters long with at least one number, one uppercase letter, one lowercase letter and one special character", ErrCodePasswordEncryptionError: "Password encryption errors: %v", ErrCodePasswordDecryptionError: "Password decryption errors: %v", ErrCodeRegexCompileError: "Unable to compile regex : %v", ErrCodeJSONMarshalError: "JSON marshal errors : %v", ErrCodeJSONUnmarshalError: "JSON unmarshal errors : %v", ErrCodeYAMLMarshalError: "YAML marshal errors : %v", ErrCodeYAMLUnmarshalError: "YAML unmarshal errors : %v", ErrCodeFileNotFound: "File '%s' was not found", ErrCodeFileCreateError: "Unable to create file '%s' : %v", ErrCodeFileRemoveError: "Unable to remove file '%s' : %v", ErrCodeFileOpenError: "Unable to open file '%s' : %v", ErrCodeFileReadError: "Unable to read file '%s' : %v", ErrCodeFileWriteError: "Unable to write to the file '%s' : %v", ErrCodeBasicAuthMissing: "Basic authentication is required", ErrCodeInvalidCredentials: "Invalid credentials", ErrCodeInvalidPayload: "Payload is not valid", ErrCodeTraceIdMissing: "Trace-Id header must be set", ErrCodeSubjectTokenTypeMissing: "Subject-Token-Type header must be set", ErrCodeSubjectTokenMissing: "Subject-Token header must be set", ErrCodeSubjectTokenTypeInvalid: "Value of header Subject-Token-Type (%s) must be one of %v", ErrCodeSubjectUnauthenticated: "Subject token is not valid", ErrCodeSubjectNotAllowed: "Insufficient access", } )
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { Code string `json:"code"` Status int `json:"status"` Message string `json:"message"` TraceId string `json:"traceId"` }
Error represents the error information.
func BadRequestError ¶
BadRequestError returns a new bad request Error.
func BadRequestErrorf ¶
BadRequestErrorf formats according to a format specifier for the message and returns a bad request Error.
func ConflictError ¶
ConflictError returns a new conflict Error.
func ConflictErrorf ¶
ConflictErrorf returns a new conflict Error.
func ForbiddenError ¶
ForbiddenError returns a new forbidden Error.
func ForbiddenErrorf ¶
ForbiddenErrorf returns a new forbidden Error.
func InternalServerError ¶
InternalServerError returns a new internal server Error.
func InternalServerErrorf ¶
InternalServerErrorf returns a new internal server Error.
func NotFoundError ¶
NotFoundError returns a new not found Error.
func NotFoundErrorf ¶
NotFoundErrorf returns a new not found Error.
func UnauthorizedError ¶
UnauthorizedError returns a new unauthorized Error.
func UnauthorizedErrorf ¶
UnauthorizedErrorf returns a new unauthorized Error.