Documentation ¶
Index ¶
- Constants
- Variables
- func NewAssertionError(e *AssertionError) error
- func NewErrorSummary(message string, errorsCh <-chan error) error
- type AssertionError
- type AssertionErrorContext
- type CommandError
- func NewErrorWithExitCode(exitCode ExitCode, err error, a ...interface{}) CommandError
- func NewServerError(r *c8y.Response, err error) CommandError
- func NewSystemError(a ...interface{}) CommandError
- func NewSystemErrorF(format string, a ...interface{}) CommandError
- func NewUserError(a ...interface{}) CommandError
- func NewUserErrorWithExitCode(exitCode ExitCode, a ...interface{}) CommandError
- type ExitCode
- type NoMatchesFoundError
Constants ¶
View Source
const ( // ErrTypeServer server error type. Server responded with an error ErrTypeServer = "serverError" // ErrTypeCommand command error. Local command error related to the usage of the tool etc. ErrTypeCommand = "commandError" // ErrTypeAssertion assertion error. ErrTypeAssertion = "assertionError" )
Variables ¶
View Source
var ErrAssertion = errors.New("assertion error")
View Source
var ErrHelp = errors.New("help text: this is not an error")
ErrHelp help error text. This error will not be displayed to the user
View Source
var ErrMoreThanOneFound = errors.New("referenceByName: more than 1 found")
View Source
var ErrNoMatchesFound = errors.New("referenceByName: no matching items found")
Functions ¶
func NewAssertionError ¶
func NewAssertionError(e *AssertionError) error
func NewErrorSummary ¶
NewErrorSummary create a error summary from a chanell of errors
Types ¶
type AssertionError ¶
type AssertionError struct { Err error `json:"err,omitempty"` Type AssertionErrorContext `json:"type,omitempty"` Message string `json:"message,omitempty"` Context interface{} `json:"context,omitempty"` Wanted interface{} `json:"wanted,omitempty"` Got interface{} `json:"got,omitempty"` }
func (*AssertionError) Error ¶
func (e *AssertionError) Error() string
func (*AssertionError) Unwrap ¶
func (e *AssertionError) Unwrap() error
type AssertionErrorContext ¶
type AssertionErrorContext string
var ( ManagedObject AssertionErrorContext = "managedObject" ManagedObjectFragments AssertionErrorContext = "managedObjectFragments" AlarmCount AssertionErrorContext = "alarmCount" EventCount AssertionErrorContext = "eventCount" MeasurementCount AssertionErrorContext = "measurementCount" OperationCount AssertionErrorContext = "operationCount" )
type CommandError ¶
type CommandError struct { ErrorType string `json:"errorType,omitempty"` Message string `json:"message,omitempty"` StatusCode int `json:"statusCode,omitempty"` ExitCode ExitCode `json:"exitCode,omitempty"` URL string `json:"url,omitempty"` CumulocityError *c8y.ErrorResponse `json:"c8yResponse,omitempty"` Err error `json:"error,omitempty"` Processed bool `json:"-"` // contains filtered or unexported fields }
CommandError is an error used to signal different error situations in command handling.
func NewErrorWithExitCode ¶
func NewErrorWithExitCode(exitCode ExitCode, err error, a ...interface{}) CommandError
NewUserErrorWithExitCode creates a user with a specific exit code
func NewServerError ¶
func NewServerError(r *c8y.Response, err error) CommandError
NewServerError creates a server error from a Cumulocity response
func NewSystemError ¶
func NewSystemError(a ...interface{}) CommandError
NewSystemError creates a system error
func NewSystemErrorF ¶
func NewSystemErrorF(format string, a ...interface{}) CommandError
NewSystemErrorF creates a custom system error
func NewUserError ¶
func NewUserError(a ...interface{}) CommandError
NewUserError creates a new user error
func NewUserErrorWithExitCode ¶
func NewUserErrorWithExitCode(exitCode ExitCode, a ...interface{}) CommandError
NewUserErrorWithExitCode creates a user with a specific exit code
func (CommandError) Error ¶
func (c CommandError) Error() string
func (CommandError) IsSilent ¶
func (c CommandError) IsSilent() bool
IsSilent returns true if the error should be silent
func (CommandError) JSONString ¶
func (c CommandError) JSONString() string
JSONString returns the json representation of the error
func (CommandError) ShortError ¶
func (c CommandError) ShortError() string
func (CommandError) Unwrap ¶
func (c CommandError) Unwrap() error
type ExitCode ¶
type ExitCode int
const ( ExitOK ExitCode = 0 // Map HTTP status codes to exit codes ExitBadRequest400 ExitCode = 40 ExitForbidden403 ExitCode = 3 ExitNotFound404 ExitCode = 4 ExitMethodNotAllowed405 ExitCode = 5 ExitConflict409 ExitCode = 9 ExitExecutionTimeout413 ExitCode = 13 ExitInvalidData422 ExitCode = 22 ExitTooManyRequests429 ExitCode = 29 ExitInternalServerError500 ExitCode = 50 ExitNotImplemented501 ExitCode = 51 ExitBadGateway502 ExitCode = 52 ExitGatewayTimeout504 ExitCode = 54 ExitHTTPVersionNotSupported505 ExitCode = 55 ExitVariantAlsoNegotiates506 ExitCode = 56 ExitInsufficientStorage507 ExitCode = 57 ExitLoopDetected508 ExitCode = 58 ExitCancel ExitCode = 2 ExitUnknownError ExitCode = 99 ExitError ExitCode = 100 ExitUserError ExitCode = 101 ExitNoSession ExitCode = 102 ExitAbortedWithErrors ExitCode = 103 ExitCompletedWithErrors ExitCode = 104 ExitJobLimitExceeded ExitCode = 105 ExitTimeout ExitCode = 106 ExitInvalidAlias ExitCode = 107 ExitDecryption ExitCode = 108 ExitAssertionError ExitCode = 112 )
type NoMatchesFoundError ¶
func NewNoMatchesFoundError ¶
func NewNoMatchesFoundError(name string) *NoMatchesFoundError
func (*NoMatchesFoundError) Error ¶
func (e *NoMatchesFoundError) Error() string
func (*NoMatchesFoundError) Unwrap ¶
func (e *NoMatchesFoundError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.