skyerr

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package skyerr contains information of errors used in skygear.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error interface {
	Name() string
	Code() ErrorCode
	Message() string
	Info() map[string]interface{}
	error
	json.Marshaler
}

Error specifies the interfaces required by an error in skygear

func MakeError

func MakeError(err error) Error

MakeError returns an Error interface with the specified error. If the specified error already implements the Error interface, the specified error is returned.

For specified error of other kinds, the returned error always have code `UnexpectedError`.

func NewError

func NewError(code ErrorCode, message string) Error

NewError returns an error suitable to be returned to the client

func NewErrorWithInfo

func NewErrorWithInfo(code ErrorCode, message string, info map[string]interface{}) Error

NewErrorWithInfo returns an Error

func NewErrorf

func NewErrorf(code ErrorCode, message string, a ...interface{}) Error

NewErrorf returns an Error

func NewInvalidArgument

func NewInvalidArgument(message string, arguments []string) Error

NewInvalidArgument is a convenient function to returns an invalid argument error with a list of arguments that are invalid.

func NewRequestJSONInvalidErr

func NewRequestJSONInvalidErr(err error) Error

NewRequestJSONInvalidErr returns new RequestJSONInvalid Error

func NewResourceDeleteFailureErrWithStringID

func NewResourceDeleteFailureErrWithStringID(kind string, id string) Error

NewResourceDeleteFailureErrWithStringID returns a new ResourceDeleteFailure Error

func NewResourceFetchFailureErr

func NewResourceFetchFailureErr(kind string, id interface{}) Error

NewResourceFetchFailureErr returns a new ResourceFetchFailure Error

func NewResourceSaveFailureErrWithStringID

func NewResourceSaveFailureErrWithStringID(kind string, id string) Error

NewResourceSaveFailureErrWithStringID returns a new ResourceSaveFailure Error with the specified kind and string id in the error message

type ErrorCode

type ErrorCode int

ErrorCode is an integer representation of an error condition occurred within the system.

const (
	// NotAuthenticated is for operations that requires authentication
	// but the request is not properly authenticated.
	NotAuthenticated ErrorCode = 101 + iota

	// PermissionDenied occurs when the requested resource or operation
	// exists, but the request is not allowed for some reason.
	PermissionDenied

	// AccessKeyNotAccepted occurs when the request contains access key
	// (API key), but the access key is not accepted.
	AccessKeyNotAccepted

	// AccessTokenNotAccepted occurs when the request contains access token
	// but the access token is not accepted.
	AccessTokenNotAccepted

	// InvalidCredentials occurs when the information supplied by a user
	// to get authenticated is incorrect.
	InvalidCredentials

	// InvalidSignature is returned by an operation that requires a signature
	// and the provided signature is not valid.
	InvalidSignature

	// BadRequest is an error when the server does not understand the request.
	//
	// The same error is used for requests that does not conform to HTTP
	// protocol.
	// The same error may be used for requests that are missing arguments.
	BadRequest

	// InvalidArgument is an error when the server understand the request,
	// but the supplied argument is not valid
	InvalidArgument

	// Duplicated is an error that occurs when a resource to be saved is
	// a duplicate of an existing resource
	Duplicated

	// ResourceNotFound is returned because the requested resource
	// is not found, and this is unlikely due to a failure.
	//
	// The same error is used for operations that require a critical resource
	// to be available, and that resource is specified in the request.
	ResourceNotFound

	// NotSupported occurs when the server understands the request,
	// but the feature is not available due to a known limitation.
	//
	// Use this when the feature is not likely to be implemented in the near
	// future.
	NotSupported

	// NotImplemented occurs when the server understands the request,
	// but the feature is not implemented yet.
	//
	// Use this when the feature is likely to be implemented in the near
	// future.
	NotImplemented

	// ConstraintViolated occurs when a resource cannot be saved because
	// doing so would violate a constraint.
	ConstraintViolated

	// IncompatibleSchema occurs if because the saving record is incompatible
	// with the existing schema.
	IncompatibleSchema

	// AtomicOperationFailure occurs when a batch operation failed because
	// it failed partially, and the batch operation is required to be atomic
	AtomicOperationFailure

	// PartialOperationFailure occurs when a batch operation failed because
	// it failed partially, and the batch operation is not required to be atomic
	PartialOperationFailure

	// UndefinedOperation is an operation that is not known to the system
	UndefinedOperation

	// PluginUnavailable occurs when the configured plugin is not available at
	// the moment
	PluginUnavailable

	// PluginTimeout occurs when an operation carried by a plugin is timed out
	PluginTimeout

	// QueryInvalid is returned when information contained in a record query
	// is not valid. Examples include referencing keypath that is invalid, and
	// unsupported comparison.
	RecordQueryInvalid

	// PluginInitializing occurs when any of the plugins are initializing
	PluginInitializing

	// ResponseTimeout occurs when an operation is taking too long to produce
	// a response
	ResponseTimeout
)

A list of all expected errors.

Naming convention: * Try not to end an error name with "Error" * "NotAccepted" refers to information that seems valid but still not accepted for some reason * "Bad" refers to information that is malformed or in a corrupted format * "Invalid" refers to information that is not correct

const (

	// UnexpectedError is for an error that is not likely to happen or
	// an error that cannot be classified into any other error type.
	//
	// Refrain from using this error code.
	UnexpectedError ErrorCode = 10000 + iota
	UnexpectedUserInfoNotFound
	UnexpectedUnableToOpenDatabase
	UnexpectedPushNotificationNotConfigured
	InternalQueryInvalid
)

A list of unexpected errors.

func (ErrorCode) String

func (i ErrorCode) String() string

Jump to

Keyboard shortcuts

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