errors

package
v0.0.0-...-695150b Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: Apache-2.0 Imports: 3 Imported by: 7

Documentation

Overview

Package errors ...

Package errors ...

Index

Constants

View Source
const (
	// InsufficientPrivileges defines the status message at the time of Insufficient Privileges
	InsufficientPrivileges = "Base.1.0.InsufficientPrivileges"
	// InternalError defines the status message at the time of Internal Error
	InternalError = "Base.1.0.InternalError"
	// PropertyMissing defines the status message at the time of Property Missing
	PropertyMissing = "Base.1.0.PropertyMissing"
	// ResourceNotFound defines the status message at the time of Resource Not Found
	ResourceNotFound = "Base.1.0.ResourceNotFound"
	// MalformedJSON defines the status message at the time of Malformed JSON
	MalformedJSON = "Base.1.0.MalformedJSON"
	// ResourceCannotBeModified defines the status message at the time of Resource Cannot Be Modified
	ResourceCannotBeModified = "Base.1.0.ResourceCannotBeModified"
	// PropertyValueNotInList defines the status message at the time of Property Value Not In List
	PropertyValueNotInList = "Base.1.0.PropertyValueNotInList"
	// NoValidSession defines the status message at the time of No Valid Session
	NoValidSession = "Base.1.0.NoValidSession"
	// UnauthorizedLoginAttempt defines the status message at the time of Unauthorized Login Attempt
	UnauthorizedLoginAttempt = "Base.1.0.UnauthorizedLoginAttempt"
	// Unauthorized defines the status message at the time of Unauthorized service wants to perform task
	Unauthorized = "Base.1.0.Unauthorized"
	// ResourceInUse defines events aleady subscribed
	ResourceInUse = "Base.1.0.ResourceInUse"
	// PropertyValueFormatError defines the status message  given the correct value type but the value of that property was not supported
	PropertyValueFormatError = "Base.1.0.PropertyValueFormatError"
	// ResourceAtURIUnauthorized defines the authorization failure with plugin or other resources
	ResourceAtURIUnauthorized = "Base.1.6.1.ResourceAtUriUnauthorized"
	// CouldNotEstablishConnection defines the connection failure with plugin or other resources
	CouldNotEstablishConnection = "Base.1.6.1.CouldNotEstablishConnection"
	// ResourceCannotBeDeleted defines the  status message at the time of Resource deletion
	ResourceCannotBeDeleted = "Base.1.6.1.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
)

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