errors

package
Version: v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: MIT Imports: 0 Imported by: 3

Documentation

Overview

Package error is a collection of error-related functionality that aims to unify all of the errors across the SDK. Specifically, it abstracts away low level errors into higher-level, easier-to-digest errors of two types: SDK errors (represented by the `Error` class) and API errors (represented by the `APIError` class).

Index

Constants

View Source
const (
	SpeechNilAudio                 = "SpeechNilAudio"
	WAVCorruptFile                 = "WAVCorruptFile"
	AudioFileOutputStreamNotOpened = "AudioFileOutputStreamNotOpened"
	AudioFileNotWritableStream     = "AudioFileNotWritableStream"
)

Define the various error codes possible

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	// Id is the request ID for which this error occurred.
	ID string `json:"id,omitempty"`

	// Status is the HTTP Status code for this error
	Status int `json:"status,omitempty"`

	// Code is the specific error code (for debugging purposes)
	Code string `json:"code,omitempty"`

	// Type is the type (BadRequest, NotFound, etc) of error
	Type string `json:"type,omitempty"`

	// Message is a descriptive message of the error, why it occurred, how to resolve, etc.
	Message string `json:"message,omitempty"`

	// Info is an optional field describing in detail the error for debugging purposes.
	Info string `json:"-"`
}

APIError is the error that is returned from API calls.

func (APIError) Error

func (e APIError) Error() string

Error converts the error to a human-readable, string format.

type Error

type Error struct {
	// Code is the specific error code (for debugging purposes)
	Code string `json:"code,omitempty"`

	// Message is a descriptive message of the error, why it occurred, how to resolve, etc.
	Message string `json:"message,omitempty"`

	// Info is an optional field describing in detail the error for debugging purposes.
	Info string `json:"-"`
}

Error is a generic error that is returned when something SDK-related goes wrong.

func NewError

func NewError(code string, message string, info string) *Error

NewError creates and `Error` object from the given information.

func NewFromErrorCode

func NewFromErrorCode(code ErrorCode) *Error

NewFromErrorCode creates an `Error` object based on a predefined code and message.

func NewFromErrorCodeInfo

func NewFromErrorCodeInfo(code ErrorCode, info string) *Error

NewFromErrorCodeInfo creates an `Error` object based on a predefined code and also includes some extra information about the error.

func (Error) Error

func (e Error) Error() string

Error converts the error to a human-readable, string format.

type ErrorCode

type ErrorCode string

ErrorCode is a code for an error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL