# README
errors
Package errors provides simple error handling primitives and behavioral errors.
go get github.com/corestoreio/errors
Read the package documentation for more information.
Contributing
We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high.
Before proposing a change, please discuss your change by raising an issue.
Licence
BSD-2-Clause
Copyright (c) 2015, Dave Cheney <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Licensing
CoreStore is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
Copyright 2015-2017, Cyrill @ Schumacher.fm and the CoreStore contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# Functions
Cause returns the underlying cause of the error, if possible.
CausedBehaviour returns the first underlying caused behaviour of the error, if possible.
Errorf formats according to a format specifier and returns the string as a value that satisfies error.
FormatLineFunc is a basic formatter that outputs the errors that occurred along with the filename and the line number of the errors.
HasBehaviour checks if err contains at least one of the provided behaviour functions.
IsAborted reports whether err was created with NewAborted() or implements interface: type Aborteder interface { Aborted() bool }.
IsAlreadyCaptured reports whether err was created with NewAlreadyCaptured() or implements interface: type AlreadyCaptureder interface { AlreadyCaptured() bool }.
IsAlreadyClosed reports whether err was created with NewAlreadyClosed() or implements interface: type AlreadyCloseder interface { AlreadyClosed() bool }.
IsAlreadyExists reports whether err was created with NewAlreadyExists() or implements interface: type AlreadyExistser interface { AlreadyExists() bool }.
IsAlreadyInUse reports whether err was created with NewAlreadyInUse() or implements interface: type AlreadyInUseer interface { AlreadyInUse() bool }.
IsAlreadyRefunded reports whether err was created with NewAlreadyRefunded() or implements interface: type AlreadyRefundeder interface { AlreadyRefunded() bool }.
IsBlocked reports whether err was created with NewBlocked() or implements interface: type Blockeder interface { Blocked() bool }.
IsConnectionFailed reports whether err was created with NewConnectionFailed() or implements interface: type ConnectionFaileder interface { ConnectionFailed() bool }.
IsDeclined reports whether err was created with NewDeclined() or implements interface: type Declineder interface { Declined() bool }.
IsDenied reports whether err was created with NewDenied() or implements interface: type Denieder interface { Denied() bool }.
IsDuplicated reports whether err was created with NewDuplicated() or implements interface: type Duplicateder interface { Duplicated() bool }.
IsEmpty reports whether err was created with NewEmpty() or implements interface: type Emptyer interface { Empty() bool }.
IsExceeded reports whether err was created with NewExceeded() or implements interface: type Exceededer interface { Exceeded() bool }.
IsExpired reports whether err was created with NewExpired() or implements interface: type Expireder interface { Expired() bool }.
IsFatal reports whether err was created with NewFatal() or implements interface: type Fataler interface { Fatal() bool }.
IsInProgress reports whether err was created with NewInProgress() or implements interface: type InProgresser interface { InProgress() bool }.
IsInsufficient reports whether err was created with NewInsufficient() or implements interface: type Insufficienter interface { Insufficient() bool }.
IsInterrupted reports whether err was created with NewInterrupted() or implements interface: type Interrupteder interface { Interrupted() bool }.
IsLocked reports whether err was created with NewLocked() or implements interface: type Lockeder interface { Locked() bool }.
IsMismatch reports whether err was created with NewMismatch() or implements interface: type Mismatcher interface { Mismatch() bool }.
IsNotAcceptable reports whether err was created with NewNotAcceptable() or implements interface: type NotAcceptableer interface { NotAcceptable() bool }.
IsNotAllowed reports whether err was created with NewNotAllowed() or implements interface: type NotAlloweder interface { NotAllowed() bool }.
IsNotFound reports whether err was created with NewNotFound() or implements interface: type NotFounder interface { NotFound() bool }.
IsNotImplemented reports whether err was created with NewNotImplemented() or implements interface: type NotImplementeder interface { NotImplemented() bool }.
IsNotRecoverable reports whether err was created with NewNotRecoverable() or implements interface: type NotRecoverableer interface { NotRecoverable() bool }.
IsNotSupported reports whether err was created with NewNotSupported() or implements interface: type NotSupporteder interface { NotSupported() bool }.
IsNotValid reports whether err was created with NewNotValid() or implements interface: type NotValider interface { NotValid() bool }.
IsOverflowed reports whether err was created with NewOverflowed() or implements interface: type Overfloweder interface { Overflowed() bool }.
IsPermissionDenied reports whether err was created with NewPermissionDenied() or implements interface: type PermissionDenieder interface { PermissionDenied() bool }.
IsQuotaExceeded reports whether err was created with NewQuotaExceeded() or implements interface: type QuotaExceededer interface { QuotaExceeded() bool }.
IsReadFailed reports whether err was created with NewReadFailed() or implements interface: type ReadFaileder interface { ReadFailed() bool }.
IsRejected reports whether err was created with NewRejected() or implements interface: type Rejecteder interface { Rejected() bool }.
IsRequired reports whether err was created with NewRequired() or implements interface: type Requireder interface { Required() bool }.
IsRestricted reports whether err was created with NewRestricted() or implements interface: type Restricteder interface { Restricted() bool }.
IsRevoked reports whether err was created with NewRevoked() or implements interface: type Revokeder interface { Revoked() bool }.
IsTemporary reports whether err was created with NewTemporary() or implements interface: type Temporaryer interface { Temporary() bool }.
IsTerminated reports whether err was created with NewTerminated() or implements interface: type Terminateder interface { Terminated() bool }.
IsTimeout reports whether err was created with NewTimeout() or implements interface: type Timeouter interface { Timeout() bool }.
IsTooLarge reports whether err was created with NewTooLarge() or implements interface: type TooLargeer interface { TooLarge() bool }.
IsUnauthorized reports whether err was created with NewUnauthorized() or implements interface: type Unauthorizeder interface { Unauthorized() bool }.
IsUnavailable reports whether err was created with NewUnavailable() or implements interface: type Unavailableer interface { Unavailable() bool }.
IsUserNotFound reports whether err was created with NewUserNotFound() or implements interface: type UserNotFounder interface { UserNotFound() bool }.
IsVerificationFailed reports whether err was created with NewVerificationFailed() or implements interface: type VerificationFaileder interface { VerificationFailed() bool }.
IsWriteFailed reports whether err was created with NewWriteFailed() or implements interface: type WriteFaileder interface { WriteFailed() bool }.
IsWrongVersion reports whether err was created with NewWrongVersion() or implements interface: type WrongVersioner interface { WrongVersion() bool }.
MultiErrContainsAll checks if err contains a behavioral error.
MultiErrContainsAny checks if err contains at least one behavioral error.
New returns an error with the supplied message.
NewAborted returns an error which wraps err that satisfies IsAborted().
NewAbortedf returns a formatted error that satisfies IsAborted().
NewAlreadyCaptured returns an error which wraps err that satisfies IsAlreadyCaptured().
NewAlreadyCapturedf returns a formatted error that satisfies IsAlreadyCaptured().
NewAlreadyClosed returns an error which wraps err that satisfies IsAlreadyClosed().
NewAlreadyClosedf returns a formatted error that satisfies IsAlreadyClosed().
NewAlreadyExists returns an error which wraps err that satisfies IsAlreadyExists().
NewAlreadyExistsf returns a formatted error that satisfies IsAlreadyExists().
NewAlreadyInUse returns an error which wraps err that satisfies IsAlreadyInUse().
NewAlreadyInUsef returns a formatted error that satisfies IsAlreadyInUse().
NewAlreadyRefunded returns an error which wraps err that satisfies IsAlreadyRefunded().
NewAlreadyRefundedf returns a formatted error that satisfies IsAlreadyRefunded().
NewBlocked returns an error which wraps err that satisfies IsBlocked().
NewBlockedf returns a formatted error that satisfies IsBlocked().
NewConnectionFailed returns an error which wraps err that satisfies IsConnectionFailed().
NewConnectionFailedf returns a formatted error that satisfies IsConnectionFailed().
NewDeclined returns an error which wraps err that satisfies IsDeclined().
NewDeclinedf returns a formatted error that satisfies IsDeclined().
NewDenied returns an error which wraps err that satisfies IsDenied().
NewDeniedf returns a formatted error that satisfies IsDenied().
NewDuplicated returns an error which wraps err that satisfies IsDuplicated().
NewDuplicatedf returns a formatted error that satisfies IsDuplicated().
NewEmpty returns an error which wraps err that satisfies IsEmpty().
NewEmptyf returns a formatted error that satisfies IsEmpty().
NewExceeded returns an error which wraps err that satisfies IsExceeded().
NewExceededf returns a formatted error that satisfies IsExceeded().
NewExpired returns an error which wraps err that satisfies IsExpired().
NewExpiredf returns a formatted error that satisfies IsExpired().
NewFatal returns an error which wraps err that satisfies IsFatal().
NewFatalf returns a formatted error that satisfies IsFatal().
NewInProgress returns an error which wraps err that satisfies IsInProgress().
NewInProgressf returns a formatted error that satisfies IsInProgress().
NewInsufficient returns an error which wraps err that satisfies IsInsufficient().
NewInsufficientf returns a formatted error that satisfies IsInsufficient().
NewInterrupted returns an error which wraps err that satisfies IsInterrupted().
NewInterruptedf returns a formatted error that satisfies IsInterrupted().
NewLocked returns an error which wraps err that satisfies IsLocked().
NewLockedf returns a formatted error that satisfies IsLocked().
NewMismatch returns an error which wraps err that satisfies IsMismatch().
NewMismatchf returns a formatted error that satisfies IsMismatch().
NewMultiErr creates a new multi error struct.
NewNotAcceptable returns an error which wraps err that satisfies IsNotAcceptable().
NewNotAcceptablef returns a formatted error that satisfies IsNotAcceptable().
NewNotAllowed returns an error which wraps err that satisfies IsNotAllowed().
NewNotAllowedf returns a formatted error that satisfies IsNotAllowed().
NewNotFound returns an error which wraps err that satisfies IsNotFound().
NewNotFoundf returns a formatted error that satisfies IsNotFound().
NewNotImplemented returns an error which wraps err that satisfies IsNotImplemented().
NewNotImplementedf returns a formatted error that satisfies IsNotImplemented().
NewNotRecoverable returns an error which wraps err that satisfies IsNotRecoverable().
NewNotRecoverablef returns a formatted error that satisfies IsNotRecoverable().
NewNotSupported returns an error which wraps err that satisfies IsNotSupported().
NewNotSupportedf returns a formatted error that satisfies IsNotSupported().
NewNotValid returns an error which wraps err that satisfies IsNotValid().
NewNotValidf returns a formatted error that satisfies IsNotValid().
NewOverflowed returns an error which wraps err that satisfies IsOverflowed().
NewOverflowedf returns a formatted error that satisfies IsOverflowed().
NewPermissionDenied returns an error which wraps err that satisfies IsPermissionDenied().
NewPermissionDeniedf returns a formatted error that satisfies IsPermissionDenied().
NewQuotaExceeded returns an error which wraps err that satisfies IsQuotaExceeded().
NewQuotaExceededf returns a formatted error that satisfies IsQuotaExceeded().
NewReadFailed returns an error which wraps err that satisfies IsReadFailed().
NewReadFailedf returns a formatted error that satisfies IsReadFailed().
NewRejected returns an error which wraps err that satisfies IsRejected().
NewRejectedf returns a formatted error that satisfies IsRejected().
NewRequired returns an error which wraps err that satisfies IsRequired().
NewRequiredf returns a formatted error that satisfies IsRequired().
NewRestricted returns an error which wraps err that satisfies IsRestricted().
NewRestrictedf returns a formatted error that satisfies IsRestricted().
NewRevoked returns an error which wraps err that satisfies IsRevoked().
NewRevokedf returns a formatted error that satisfies IsRevoked().
NewTemporary returns an error which wraps err that satisfies IsTemporary().
NewTemporaryf returns a formatted error that satisfies IsTemporary().
NewTerminated returns an error which wraps err that satisfies IsTerminated().
NewTerminatedf returns a formatted error that satisfies IsTerminated().
NewTimeout returns an error which wraps err that satisfies IsTimeout().
NewTimeoutf returns a formatted error that satisfies IsTimeout().
NewTooLarge returns an error which wraps err that satisfies IsTooLarge().
NewTooLargef returns a formatted error that satisfies IsTooLarge().
NewUnauthorized returns an error which wraps err that satisfies IsUnauthorized().
NewUnauthorizedf returns a formatted error that satisfies IsUnauthorized().
NewUnavailable returns an error which wraps err that satisfies IsUnavailable().
NewUnavailablef returns a formatted error that satisfies IsUnavailable().
NewUserNotFound returns an error which wraps err that satisfies IsUserNotFound().
NewUserNotFoundf returns a formatted error that satisfies IsUserNotFound().
NewVerificationFailed returns an error which wraps err that satisfies IsVerificationFailed().
NewVerificationFailedf returns a formatted error that satisfies IsVerificationFailed().
NewWriteFailed returns an error which wraps err that satisfies IsWriteFailed().
NewWriteFailedf returns a formatted error that satisfies IsWriteFailed().
NewWrongVersion returns an error which wraps err that satisfies IsWrongVersion().
NewWrongVersionf returns a formatted error that satisfies IsWrongVersion().
WithMessage annotates err with a new message.
WithStack annotates err with a stack trace at the point WithStack was called.
Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message.
Wrapf returns an error annotating err with a stack trace at the point Wrapf is call, and the format specifier.
# Type aliases
BehaviourFunc defines the signature needed for a function to check if an error has a specific behaviour attached.
Error type can be used for constant errors and says nothing about its behaviour.
ErrorFormatFunc is a function callback that is called by Error to turn the list of errors into a string.
Frame represents a program counter inside a stack frame.
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).