code

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package code defines error codes for Bifrost server.

Index

Constants

View Source
const (
	// ErrSuccess - 200: OK.
	ErrSuccess int = iota + 100001

	// ErrUnknown - 500: Internal server error.
	ErrUnknown

	// ErrBind - 400: Error occurred while binding the request body to the struct.
	ErrBind

	// ErrValidation - 400: Validation failed.
	ErrValidation

	// ErrTokenInvalid - 401: Token invalid.
	ErrTokenInvalid

	// ErrPageNotFound - 404: Page not found.
	ErrPageNotFound

	// ErrRequestTimeout - 408: Request timeout.
	ErrRequestTimeout
)

Common: basic errors. Code must start with 1xxxxx.

View Source
const (
	// ErrEncrypt - 401: Error occurred while encrypting the user password.
	ErrEncrypt int = iota + 100301

	// ErrSignatureInvalid - 401: Signature is invalid.
	ErrSignatureInvalid

	// ErrExpired - 401: Token expired.
	ErrExpired

	// ErrInvalidAuthHeader - 401: Invalid authorization header.
	ErrInvalidAuthHeader

	// ErrMissingHeader - 401: The `Authorization` header was empty.
	ErrMissingHeader

	// ErrUserOrPasswordIncorrect - 401: User or Password was incorrect.
	ErrUserOrPasswordIncorrect

	// ErrPermissionDenied - 403: Permission denied.
	ErrPermissionDenied

	// ErrAuthnClientInitFailed - 500: The `Authentication` client initialization failed.
	ErrAuthnClientInitFailed

	// ErrAuthClientNotInit - 500: The `Authentication` and `Authorization` client not initialized.
	ErrAuthClientNotInit

	// ErrConnToAuthServerFailed - 500: Failed to connect to `Authentication` and `Authorization` server.
	ErrConnToAuthServerFailed
)

common: authorization and authentication errors.

View Source
const (
	// ErrEncodingFailed - 500: Encoding failed due to an error with the data.
	ErrEncodingFailed int = iota + 100401

	// ErrDecodingFailed - 500: Decoding failed due to an error with the data.
	ErrDecodingFailed

	// ErrInvalidJSON - 500: Data is not valid JSON.
	ErrInvalidJSON

	// ErrEncodingJSON - 500: JSON data could not be encoded.
	ErrEncodingJSON

	// ErrDecodingJSON - 500: JSON data could not be decoded.
	ErrDecodingJSON

	// ErrInvalidYaml - 500: Data is not valid Yaml.
	ErrInvalidYaml

	// ErrEncodingYaml - 500: Yaml data could not be encoded.
	ErrEncodingYaml

	// ErrDecodingYaml - 500: Yaml data could not be decoded.
	ErrDecodingYaml
)

common: encode/decode errors.

View Source
const (
	// ErrConfigurationTypeMismatch - 500: Configuration type mismatch.
	ErrConfigurationTypeMismatch int = iota + 110001

	// ErrSameConfigFingerprint - 500: Same config fingerprint.
	ErrSameConfigFingerprint

	// ErrSameConfigFingerprints - 500: Same config fingerprint between files and configuration.
	ErrSameConfigFingerprints

	// ErrConfigManagerIsRunning - 500: Config manager is running.
	ErrConfigManagerIsRunning

	// ErrConfigManagerIsNotRunning - 500: Config manager is not running.
	ErrConfigManagerIsNotRunning

	// ErrConfigurationNotFound - 400: Web server configuration not found.
	ErrConfigurationNotFound

	// ErrParserNotFound - 500: Parser not found.
	ErrParserNotFound

	// ErrUnknownKeywordString - 500: Unknown keyword string.
	ErrUnknownKeywordString

	// ErrInvalidConfig - 500: Invalid parser.Config.
	ErrInvalidConfig

	// ErrParseFailed - 500: Config parse failed.
	ErrParseFailed

	// ErrV3ContextIndexOutOfRange - 500: Index of the Context's children is out of range.
	ErrV3ContextIndexOutOfRange

	// ErrV3NullContextPosition - 500: Null Context position.
	ErrV3NullContextPosition

	// ErrV3SetFatherContextFailed - 500: Set father Context failed.
	ErrV3SetFatherContextFailed

	// ErrV3OperationOnErrorContext - 500: Performing operations on Error Context.
	ErrV3OperationOnErrorContext

	// ErrV3InvalidContext - 500: Invalid Context.
	ErrV3InvalidContext

	// ErrV3InvalidOperation - 500: Invalid operation.
	ErrV3InvalidOperation

	// ErrV3ContextNotFound - 500: Queried context not found.
	ErrV3ContextNotFound
)

bifrost: configuration errors.

View Source
const (
	// ErrStopMonitoringTimeout - 500: Stop monitoring timeout.
	ErrStopMonitoringTimeout int = iota + 110201

	// ErrMonitoringServiceSuspension - 500: Monitoring service suspension.
	ErrMonitoringServiceSuspension

	// ErrMonitoringStarted - 500: Monitoring is already started.
	ErrMonitoringStarted
)

bifrost: metrics errors.

View Source
const (
	// ErrLogsDirPath - 500: Logs dir is not exist or is not a directory.
	ErrLogsDirPath int = iota + 110301

	// ErrLogBufferIsNotExist - 500: Log buffer is not exist.
	ErrLogBufferIsNotExist

	// ErrLogBufferIsExist - 500: Log buffer is already exist.
	ErrLogBufferIsExist

	// ErrLogIsLocked - 500: Log is locked.
	ErrLogIsLocked

	// ErrLogIsUnlocked - 500: Log is unlocked.
	ErrLogIsUnlocked

	// ErrUnknownLockError - 500: Unknown lock error.
	ErrUnknownLockError
)

bifrost: log watch errors.

View Source
const (
	// ErrDataRepository - 500: Data Repository error.
	ErrDataRepository int = iota + 100201
)

common: data repository errors.

View Source
const (
	// ErrDatabase - 500: Database error.
	ErrDatabase int = iota + 100101
)

common: database errors.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrCode

type ErrCode struct {
	// C refers to the code of the ErrCode.
	C int

	// HTTP status that should be used for the associated error code.
	HTTP int

	// External (user) facing error text.
	Ext string

	// Ref specify the reference document.
	Ref string
}

ErrCode implements `github.com/marmotedu/errors`.Coder interface.

func (ErrCode) Code

func (coder ErrCode) Code() int

Code returns the integer code of ErrCode.

func (ErrCode) HTTPStatus

func (coder ErrCode) HTTPStatus() int

HTTPStatus returns the associated HTTP status code, if any. Otherwise, returns 200.

func (ErrCode) Reference

func (coder ErrCode) Reference() string

Reference returns the reference document.

func (ErrCode) String

func (coder ErrCode) String() string

String implements stringer. String returns the external error message, if any.

Jump to

Keyboard shortcuts

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