Newer
Older
Fabian Seidl
committed
package customerrs
"github.com/openconfig/ygot/ygot"
Fabian Seidl
committed
// NilClientError implements the Error interface and is called if a GNMI Client is nil.
type NilClientError struct {
Fabian Seidl
committed
func (e *NilClientError) Error() string {
return fmt.Sprint("client cannot be nil")
Fabian Seidl
committed
// NilError implements the Error interface and is called if a struct is nil.
type NilError struct {
Fabian Seidl
committed
func (e *NilError) Error() string {
return fmt.Sprint("struct cannot be nil")
Fabian Seidl
committed
// AlreadyExistsError implements the Error interface and is called if a specific ID
Fabian Seidl
committed
type AlreadyExistsError struct {
Fabian Seidl
committed
func (e *AlreadyExistsError) Error() string {
return fmt.Sprintf("%T %v already exists", e.Item, e.Item)
Fabian Seidl
committed
// InvalidUUIDError implements the Error interface and is called if a UUID is not valid.
type InvalidUUIDError struct {
Fabian Seidl
committed
func (e *InvalidUUIDError) Error() string {
return fmt.Sprint("UUID not valid")
Fabian Seidl
committed
// InvalidTypeAssertionError implements the Error interface and is called if the
// type of a storable item does not correspond to the expected type.
Fabian Seidl
committed
type InvalidTypeAssertionError struct {
Fabian Seidl
committed
func (e InvalidTypeAssertionError) Error() string {
return fmt.Sprintf("%v does not implement %v", reflect.TypeOf(e.Value).Elem(), reflect.TypeOf(e.Type).Elem())
Fabian Seidl
committed
// UnsupportedPathError implements the Error interface and is called if the
Fabian Seidl
committed
type UnsupportedPathError struct {
Fabian Seidl
committed
func (e UnsupportedPathError) Error() string {
return fmt.Sprintf("path %v is not supported", e.Path)
Fabian Seidl
committed
// PathNotFoundError implements the Error interface and is called if the
// given path is not supported.
Fabian Seidl
committed
type PathNotFoundError struct {
Path interface{}
Err error
}
Fabian Seidl
committed
func (e PathNotFoundError) Error() string {
return fmt.Sprintf("path %v not found: %v", e.Path, e.Err)
}
Fabian Seidl
committed
// NotYetImplementedError implements the Error interface and is called if a function
Fabian Seidl
committed
type NotYetImplementedError struct{}
Fabian Seidl
committed
func (e NotYetImplementedError) Error() string {
return fmt.Sprint("function not yet implemented")
Fabian Seidl
committed
// InvalidParametersError implements the Error interface and is called if the wrong
Fabian Seidl
committed
type InvalidParametersError struct {
Fabian Seidl
committed
func (e InvalidParametersError) Error() string {
return fmt.Sprintf("invalid parameters for %v: %v", e.Func, e.Param)
Fabian Seidl
committed
// InvalidTransportOptionsError implements the Error interface and is called if the
Fabian Seidl
committed
type InvalidTransportOptionsError struct {
Fabian Seidl
committed
func (e InvalidTransportOptionsError) Error() string {
return fmt.Sprintf("invalid transport options: %v", reflect.TypeOf(e.Opt))
Fabian Seidl
committed
// OperationNotSupportedError implements the Error interface and is called if the
Fabian Seidl
committed
type OperationNotSupportedError struct {
Fabian Seidl
committed
func (e OperationNotSupportedError) Error() string {
return fmt.Sprintf("transport operation not supported: %v", reflect.TypeOf(e.Op))
Fabian Seidl
committed
// UnsupportedSbiTypeError implements the Error interface and is called if the
// wrong Type for a SBI has been provided.
Fabian Seidl
committed
type UnsupportedSbiTypeError struct {
Type interface{}
}
Fabian Seidl
committed
func (e UnsupportedSbiTypeError) Error() string {
return fmt.Sprintf("SBI type not supported: %v", e.Type)
}
Fabian Seidl
committed
// PluginVersionError implements the Error interface and is called if the Version
// of a Plugin is older than a Plugin in use.
Fabian Seidl
committed
type PluginVersionError struct {
PlugID, ProvidedVer, UsedVer string
}
Fabian Seidl
committed
func (e PluginVersionError) Error() string {
return fmt.Sprintf("Version of Plugin: %s is older than the one in use. Provided: %s, in use: %s", e.PlugID, e.ProvidedVer, e.UsedVer)
}
Fabian Seidl
committed
// CombinedErrListError implements the Error interface and is called if a slice of errors
// should be returned. The slice of errors is combined into a single error
// message and returned.
Fabian Seidl
committed
type CombinedErrListError struct {
Errors []error
}
Fabian Seidl
committed
func (e CombinedErrListError) Error() string {
combinedErrString := "Errors found:"
for i, err := range e.Errors {
errString := fmt.Sprintf("\n %v. %v", i+1, err)
combinedErrString = combinedErrString + errString
}
return combinedErrString
}
Fabian Seidl
committed
// TypeNotSupportedError implements the Error interface and is called if the
Fabian Seidl
committed
type TypeNotSupportedError struct {
Fabian Seidl
committed
func (e TypeNotSupportedError) Error() string {
return fmt.Sprintf("type not supported: %v", reflect.TypeOf(e.Type))
}
Fabian Seidl
committed
// CouldNotMarshallError implements Error interface and is called if a
// database response can not be parsed.
Fabian Seidl
committed
type CouldNotMarshallError struct {
Identifier any
Type any
Err error
}
Fabian Seidl
committed
func (e CouldNotMarshallError) Error() string {
return fmt.Sprintf("could not marshall Identifier: %v of Type: %T, Internal error: %v", e.Identifier, e.Type, e.Err)
}
Fabian Seidl
committed
// CouldNotUpdateError implements the Error interface and is called if a
// stored item can not be updated.
Fabian Seidl
committed
type CouldNotUpdateError struct {
Identifier any
Type any
Err error
}
Fabian Seidl
committed
func (e CouldNotUpdateError) Error() string {
return fmt.Sprintf("could not update Identifier: %v of Type: %T, Internal error: %v", e.Identifier, e.Type, e.Err)
}
Fabian Seidl
committed
// CouldNotFindError implements the Error interface and is called if a
// stored item can not be found.
Fabian Seidl
committed
type CouldNotFindError struct {
Fabian Seidl
committed
ID any
Name string
}
Fabian Seidl
committed
func (e CouldNotFindError) Error() string {
Fabian Seidl
committed
return fmt.Sprintf("ID: %v or Name: %v not found", e.ID, e.Name)
}
Fabian Seidl
committed
// CouldNotCreateError implements the Error interface and is called if a
// stored item can not be found.
Fabian Seidl
committed
type CouldNotCreateError struct {
Identifier any
Type any
Err error
}
Fabian Seidl
committed
func (e CouldNotCreateError) Error() string {
return fmt.Sprintf("could not create Identifier: %v of Type: %T, Internal error: %v", e.Identifier, e.Type, e.Err)
}
Fabian Seidl
committed
// CouldNotDeleteError implements the Error interface and is called if a
// stored item can not be deleted.
Fabian Seidl
committed
type CouldNotDeleteError struct {
Identifier any
Type any
Err error
Fabian Seidl
committed
func (e CouldNotDeleteError) Error() string {
return fmt.Sprintf("could not delete Identifier: %v of Type: %T, Internal error: %v", e.Identifier, e.Type, e.Err)
Fabian Seidl
committed
// NoNewChangesError implements the Error interface and is called if a the
// gNMI-Notification created from ygot.Diff does not contain any `updates` or
// `deletes`.
Fabian Seidl
committed
type NoNewChangesError struct {
Original ygot.GoStruct
Modified ygot.GoStruct
}
Fabian Seidl
committed
func (e NoNewChangesError) Error() string {
return fmt.Sprintf("There are no changes between %v and %v", e.Original, e.Modified)
}
Fabian Seidl
committed
Fabian Seidl
committed
// AMQPInitFailError implements the Error interface and is called if there is any issue related to
Fabian Seidl
committed
// the setup of the event management.
Fabian Seidl
committed
type AMQPInitFailError struct {
Fabian Seidl
committed
Action string
Err error
}
Fabian Seidl
committed
func (e AMQPInitFailError) Error() string {
Fabian Seidl
committed
return fmt.Sprintf("Action: %s, Internal error: %v", e.Action, e.Err)
}
Fabian Seidl
committed
// AMQPMessageFailError implements the Error interface and is called if there is any issue with sending
Fabian Seidl
committed
// or receiving messages.
Fabian Seidl
committed
type AMQPMessageFailError struct {
Fabian Seidl
committed
Action string
Err error
}
Fabian Seidl
committed
func (e AMQPMessageFailError) Error() string {
Fabian Seidl
committed
return fmt.Sprintf("Action: %s, Internal error: %v", e.Action, e.Err)
}
Fabian Seidl
committed
// SubscribeResponseError implements the Error interface and is called if there is an issue during a ongoing
// gNMI Subscription.
Fabian Seidl
committed
type SubscribeResponseError struct {
PndID string
NetworkElementID string
NetworkElementName string
Err string
Fabian Seidl
committed
func (e SubscribeResponseError) Error() string {
return fmt.Sprintf("Subscribe failed, PndID: %s, NetworkElementID: %s, NetworkElementName: %s, Internal error: %s", e.PndID, e.NetworkElementID, e.NetworkElementName, e.Err)
Fabian Seidl
committed
// SubscribeSyncResponseError implements the Error interface and is called if there is an issue syncing a
// gNMI Subscription.
Fabian Seidl
committed
type SubscribeSyncResponseError struct {
PndID string
NetworkElementID string
NetworkElementName string
Fabian Seidl
committed
func (e SubscribeSyncResponseError) Error() string {
return fmt.Sprintf("Sync failed, PndID: %s, NetworkElementID: %s, NetworkElementName: %s", e.PndID, e.NetworkElementID, e.NetworkElementName)