lrerror

package
v0.0.0-...-c7849f8 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package lrerr represents API error interface accessors for the SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SprintError

func SprintError(code, message, extra string, origErr error) string

SprintError returns a string of the formatted error code.

Both extra and origErr are optional. If they are included their lines will be added, but if they are not included their lines will be ignored.

Types

type BatchError

type BatchError interface {
	// Satisfy the generic error interface.
	error

	// Returns the short phrase depicting the classification of the error.
	Code() string

	// Returns the error details message.
	Message() string

	// Returns the original error if one was set.  Nil is returned if not set.
	OrigErrs() []error
}

type BatchedErrors

type BatchedErrors interface {
	// Satisfy the base Error interface.
	Error

	// Returns the original error if one was set.  Nil is returned if not set.
	OrigErrs() []error
}

BatchedErrors is a batch of errors which also wraps lower level errors with code, message, and original errors. Calling Error() will include all errors that occurred in the batch.

Replaces BatchError

func NewBatchError

func NewBatchError(code, message string, errs []error) BatchedErrors

NewBatchError returns an BatchedErrors with a collection of errors as an array of errors.

type Error

type Error interface {
	// Satisfy the generic error interface.
	error

	// Returns the short phrase depicting the classification of the error.
	Code() string

	// Returns the error details message.
	Message() string

	// Returns the original error if one was set.  Nil is returned if not set.
	OrigErr() error
}

An Error wraps lower level errors with code, message and an original error. The underlying concrete error type may also satisfy other interfaces which can be to used to obtain more specific information about the error.

Calling Error() or String() will always include the full information about an error based on its underlying type.

Example:

output, err := loginradius.GetAuthVerifyEmail()
if err != nil {
    if lrError, ok := err.(lrError.Error); ok {
        // Get error details
        log.Println("Error:", lrError.Code(), lrError.Message())

        // Prints out full error message, including original error if there was one.
        log.Println("Error:", lrError.Error())

        // Get original error
        if origErr := lrError.OrigErr(); origErr != nil {
            // operate on original error.
        }
    } else {
        ...
    }
}

func New

func New(code, message string, origErr error) Error

New returns an Error object described by the code, message, and origErr.

If origErr satisfies the Error interface it will not be wrapped within a new Error object and will instead be returned.

type ErrorResponse

type ErrorResponse struct {
	ErrorCode       int
	Description     string
	IsProviderError bool
	Message         string
}

Jump to

Keyboard shortcuts

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