apperrors

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: GPL-2.0 Imports: 3 Imported by: 5

Documentation

Overview

Package apperrors contains OTA application error definition and all error types

Index

Constants

View Source
const (
	// ErrorDataSerialization is error type returned if data.ObjectID was not serialized successfully
	ErrorDataSerialization = ErrorNamespaceData + ":Serialization"
	// ErrorDataValidation is error type returned if data.Ref is not pass validation
	ErrorDataValidation = ErrorNamespaceData + ":Validation"
)
View Source
const (
	// ErrorDbConnection is error type related to establishing connection to db server
	ErrorDbConnection = ErrorNamespaceDB + ":ConnectionError"
	// ErrorDbOperation is error type related to execution db CRUD operations
	ErrorDbOperation = ErrorNamespaceDB + ":OperationError"
	// ErrorDbNoDocumentFound is error type returned if no document found
	ErrorDbNoDocumentFound = ErrorNamespaceDB + ":DocumentNotFound"
	// ErrorDbAlreadyExist is error type returned on creation of document if document with doc id already exists
	ErrorDbAlreadyExist = ErrorNamespaceDB + ":DocumentAlreadyExist"
)
View Source
const (
	// ErrorFsPath is error type related file path availability
	ErrorFsPath = ErrorNamespaceFs + ":PathNotExist"
	// ErrorFsIOOpen is error type related opening file
	ErrorFsIOOpen = ErrorNamespaceFs + ":IOOpen"
	// ErrorFsIOOperation is error type related file io operations
	ErrorFsIOOperation = ErrorNamespaceFs + ":IOOperation"
	// ErrorFsIOCreate is error type related file creating operation
	ErrorFsIOCreate = ErrorNamespaceFs + ":IOCreate"
)
View Source
const (
	// ErrorNamespaceDB is error namespace for error related to database operations
	ErrorNamespaceDB = "db"
	// ErrorNamespaceData is error namespace for error related for data transformation/validation
	ErrorNamespaceData = "data"
	// ErrorNamespaceFs is error namespace for error related for file read/write operations
	ErrorNamespaceFs = "fs"
	// ErrorNamespaceSvc is error namespace for error related igh level business logic
	ErrorNamespaceSvc = "svc"

	// ErrorGeneric is untyped error
	ErrorGeneric = "generic-error"
)
View Source
const (
	// ErrorSvcEntityExists is error to incorrect user operation( try accidentally replacing some entity)
	ErrorSvcEntityExists = ErrorNamespaceSvc + ":EntityAlreadyExist"
)

Variables

This section is empty.

Functions

func CreateError

func CreateError(code AppErrorCode, descr string, err error) error

CreateError create new AppError

func CreateErrorAndLogIt

func CreateErrorAndLogIt(log logger.Logger, code AppErrorCode, descr string, err error) error

CreateErrorAndLogIt create log record and throw an error

func NewAppError

func NewAppError(code AppErrorCode, descr string) error

NewAppError creates new AppError

Types

type AppError

type AppError struct {
	// ErrorCode application error code
	ErrorCode AppErrorCode `json:"error_code"`
	// Description description of error
	Description string `json:"description"`
}

AppError application error with additional details

func ToAppError added in v1.1.4

func ToAppError(err error) *AppError

ToAppError unwrap generic error to AppError or create AppErrorCode with ErrorGeneric code

func ToAppErrorWithCode added in v1.1.4

func ToAppErrorWithCode(err error, code AppErrorCode) *AppError

ToAppErrorWithCode unwrap generic error to AppError or create AppErrorCode with provided code

func (AppError) Error

func (err AppError) Error() string

type AppErrorCode

type AppErrorCode string

AppErrorCode is a type of AppError each code should be in format "namespace:error_code" namespace value should be unique across application error_code should be unique across package

Jump to

Keyboard shortcuts

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