errors

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrCodeBadRequest                    = "BAD_REQUEST"
	ErrCodeUnauthorized                  = "UNAUTHORIZED"
	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

View Source
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

func BadRequestError(message string) *Error

BadRequestError returns a new bad request Error.

func BadRequestErrorf

func BadRequestErrorf(format string, a ...any) *Error

BadRequestErrorf formats according to a format specifier for the message and returns a bad request Error.

func ConflictError

func ConflictError(message string) *Error

ConflictError returns a new conflict Error.

func ConflictErrorf

func ConflictErrorf(format string, a ...any) *Error

ConflictErrorf returns a new conflict Error.

func ForbiddenError

func ForbiddenError(message string) *Error

ForbiddenError returns a new forbidden Error.

func ForbiddenErrorf

func ForbiddenErrorf(format string, a ...any) *Error

ForbiddenErrorf returns a new forbidden Error.

func InternalServerError

func InternalServerError(message string) *Error

InternalServerError returns a new internal server Error.

func InternalServerErrorf

func InternalServerErrorf(format string, a ...any) *Error

InternalServerErrorf returns a new internal server Error.

func New

func New(code string, status int, message string) *Error

New returns an Error

func Newf

func Newf(code string, status int, format string, a ...any) *Error

Newf formats according to a format specifier for the message and returns the Error.

func NotFoundError

func NotFoundError(message string) *Error

NotFoundError returns a new not found Error.

func NotFoundErrorf

func NotFoundErrorf(format string, a ...any) *Error

NotFoundErrorf returns a new not found Error.

func UnauthorizedError

func UnauthorizedError(message string) *Error

UnauthorizedError returns a new unauthorized Error.

func UnauthorizedErrorf

func UnauthorizedErrorf(format string, a ...any) *Error

UnauthorizedErrorf returns a new unauthorized Error.

type Errors

type Errors struct {
	Errors []Error `json:"errors"`
}

Errors represents a list of Error.

Jump to

Keyboard shortcuts

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