errors

package
v0.0.0-...-81c02da Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 3 Imported by: 31

Documentation

Overview

Package errors ...

Package errors ...

Index

Constants

View Source
const (
	// BaseVersion defines the latest version of Base
	BaseVersion = "Base.1.13.0."
	// InsufficientPrivileges defines the status message at the time of Insufficient Privileges
	InsufficientPrivileges = BaseVersion + "InsufficientPrivilege"
	// InternalError defines the status message at the time of Internal Error
	InternalError = BaseVersion + "InternalError"
	// PropertyMissing defines the status message at the time of Property Missing
	PropertyMissing = BaseVersion + "PropertyMissing"
	// ResourceNotFound defines the status message at the time of Resource Not Found
	ResourceNotFound = BaseVersion + "ResourceNotFound"
	// MalformedJSON defines the status message at the time of Malformed JSON
	MalformedJSON = BaseVersion + "MalformedJSON"
	// ResourceCannotBeModified defines the status message at the time of Resource Cannot Be Modified
	ResourceCannotBeModified = BaseVersion + "ResourceCannotBeModified"
	// PropertyValueNotInList defines the status message at the time of Property Value Not In List
	PropertyValueNotInList = BaseVersion + "PropertyValueNotInList"
	// NoValidSession defines the status message at the time of No Valid Session
	NoValidSession = BaseVersion + "NoValidSession"
	// UnauthorizedLoginAttempt defines the status message at the time of Unauthorized Login Attempt
	UnauthorizedLoginAttempt = BaseVersion + "UnauthorizedLoginAttempt"
	// Unauthorized defines the status message at the time of Unauthorized service wants to perform task
	Unauthorized = BaseVersion + "Unauthorized"
	// ResourceInUse defines events aleady subscribed
	ResourceInUse = BaseVersion + "ResourceInUse"
	// PropertyValueFormatError defines the status message  given the correct value type but the value of that property was not supported
	PropertyValueFormatError = BaseVersion + "PropertyValueFormatError"
	// ResourceAtURIUnauthorized defines the authorization failure with plugin or other resources
	ResourceAtURIUnauthorized = BaseVersion + "ResourceAtUriUnauthorized"
	// CouldNotEstablishConnection defines the connection failure with plugin or other resources
	CouldNotEstablishConnection = BaseVersion + "CouldNotEstablishConnection"
	// ResourceCannotBeDeleted defines the  status message at the time of Resource deletion
	ResourceCannotBeDeleted = BaseVersion + "ResourceCannotBeDeleted"
)
View Source
const (
	// SystemNotSupportedErrString is used for matching unsupported server error
	SystemNotSupportedErrString = "computer system is not supported"
)

constants defined for matching partial strings in error returned

Variables

This section is empty.

Functions

func CreateErrResp

func CreateErrResp(code string, errorMessage string) interface{}

CreateErrResp defines the creation of the error message response body without exteneded info

func CreateErrorResponse

func CreateErrorResponse(statusMessage string, errorMessage string) interface{}

CreateErrorResponse defines the creation of the error message response body. As input the fuction takes status message and the error message and will create the response according to statusMessage

Types

type CommonError

type CommonError struct {
	Error ErrorClass `json:"error"`
}

CommonError struct definition

type ErrType

type ErrType int

ErrType defines the error type

const (
	// UndefinedErrorType to be used when error type is of no significance to the caller
	UndefinedErrorType ErrType = iota + 1
	// DBKeyFetchFailed indicates DB read action failed
	DBKeyFetchFailed
	// DBKeyNotFound indicates DB read failure of non-existent key
	DBKeyNotFound
	// DBKeyAlreadyExist indicates failure for DB insert of already existing key
	DBKeyAlreadyExist
	// DBConnFailed indicates failure to establish connection with DB
	DBConnFailed
	// InvalidAuthToken indicates presented authentication token is invalid
	InvalidAuthToken
	// JSONUnmarshalFailed indicates JSON unmarshaling of data failed
	JSONUnmarshalFailed
	// DecryptionFailed indicates decryption of data failed
	DecryptionFailed
	// DBUpdateFailed indicates failure in updating DB
	DBUpdateFailed
	// TransactionPartialFailure indicates some of the operations in transaction failed
	TransactionPartiallyFailed
	// TimeoutError indicates that the operation is canceled as timeout error occurred.
	TimeoutError
)

enum defined for error types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error contains the error number and error string Error number to be used for comparision of error type instead of error string

func PackError

func PackError(errno ErrType, errmsg ...interface{}) *Error

PackError defines creation of error response, which packs relevant error number and the error message

func (*Error) ErrNo

func (err *Error) ErrNo() ErrType

ErrNo to be used for obtaining the error number

func (*Error) Error

func (err *Error) Error() string

Error to be used for obtaining the error message as string type

func (*Error) GetAuthStatusCodeAndMessage

func (err *Error) GetAuthStatusCodeAndMessage() (int32, string)

GetAuthStatusCodeAndMessage will return suitable status code status message for failures

func (*Error) String

func (err *Error) String() error

String to be used for obtaining error message as error type

type ErrorClass

type ErrorClass struct {
	Code                string            `json:"code"`
	Message             string            `json:"message"`
	MessageExtendedInfo []MsgExtendedInfo `json:"@Message.ExtendedInfo,omitempty"`
}

ErrorClass struct definition

type MsgExtendedInfo

type MsgExtendedInfo struct {
	OdataType  string `json:"@odata.type,omitempty"`
	MessageID  string `json:"MessageId,omitempty"`
	Message    string `json:"Message,omitempty"`
	Severity   string `json:"Severity,omitempty"`
	Resolution string `json:"Resolution,omitempty"`
}

MsgExtendedInfo struct definition

Jump to

Keyboard shortcuts

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