Documentation ¶
Overview ¶
Example (WriteHttpJSON) ¶
writeHttpJSON(context.Background(), os.Stdout, fmt.Errorf("dummy error"), true)
Output: {"error":{"message":"dummy error"}}
Example (WriteHttpJSON_clientAbortedConnectionPipe) ¶
writeHttpJSON(context.Background(), os.Stdout, syscall.EPIPE, true)
Output:
Example (WriteHttpJSON_clientAbortedConnectionReset) ¶
writeHttpJSON(context.Background(), os.Stdout, syscall.ECONNRESET, true)
Output:
Example (WriteHttpPlain) ¶
writeHttpPlain(os.Stdout, fmt.Errorf("dummy error"), true)
Output: Error: dummy error
Example (WriteHttpPlain_clientAbortedConnectionPipe) ¶
writeHttpPlain(os.Stdout, syscall.EPIPE, true)
Output:
Example (WriteHttpPlain_clientAbortedConnectionReset) ¶
writeHttpPlain(os.Stdout, syscall.ECONNRESET, true)
Output:
Example (WriteHttpPlain_masked) ¶
err := New(0, "dummy error", Meta("a", "b"), Meta(&Error{}, "nope")) err.stack = nil // will not test the stack as file path & line numbers might change writeHttpPlain(os.Stdout, err, true)
Output: Error: dummy error
Example (WriteHttpPlain_unmasked) ¶
err := New(0, "dummy error", Meta("a", "b"), Meta(&Error{}, "nope")) err.stack = nil // will not test the stack as file path & line numbers might change writeHttpPlain(os.Stdout, err, false)
Output: Error: dummy error -------------------------------------------------------------------------------- a: b --------------------------------------------------------------------------------
Index ¶
- Constants
- func AddNodeStack(stack []string) mfn
- func As(err error, target interface{}) bool
- func Is(err, target error) bool
- func IsAny(err error) bool
- func IsAutomation(err error) bool
- func IsDuplicateData(err error) bool
- func IsExternal(err error) bool
- func IsInternal(err error) bool
- func IsInvalidData(err error) bool
- func IsKind(err error, k kind) bool
- func IsNotFound(err error) bool
- func IsObjStore(err error) bool
- func IsSensitiveData(err error) bool
- func IsStaleData(err error) bool
- func IsStore(err error) bool
- func IsUnauthenticated(err error) bool
- func IsUnauthorized(err error) bool
- func Meta(k, v interface{}) mfn
- func MetaTrim(kk ...interface{}) mfn
- func ProperlyServeHTTP(w http.ResponseWriter, r *http.Request, err error, mask bool)
- func ServeHTTP(w http.ResponseWriter, r *http.Request, err error, mask bool)
- func ServeHTTPWithCode(w http.ResponseWriter, r *http.Request, code int, err error, mask bool)
- func StackSkip(n int) mfn
- func StackTrim(n int) mfn
- func StackTrimAtFn(fn string) mfn
- func Unwrap(err error) error
- func Wrap(w error) mfn
- type Error
- func Automation(m string, aa ...interface{}) *Error
- func DuplicateData(m string, aa ...interface{}) *Error
- func External(m string, aa ...interface{}) *Error
- func Internal(m string, aa ...interface{}) *Error
- func InvalidData(m string, aa ...interface{}) *Error
- func New(k kind, m string, fn ...mfn) *Error
- func Newf(k kind, m string, a ...interface{}) *Error
- func NotFound(m string, aa ...interface{}) *Error
- func ObjStore(m string, aa ...interface{}) *Error
- func Plain(k kind, m string, a ...interface{}) *Error
- func SensitiveData(m string, aa ...interface{}) *Error
- func StaleData(m string, aa ...interface{}) *Error
- func Store(m string, aa ...interface{}) *Error
- func Unauthenticated(m string, aa ...interface{}) *Error
- func Unauthorized(m string, aa ...interface{}) *Error
- func (e *Error) Apply(ffn ...mfn) *Error
- func (e Error) Error() string
- func (e *Error) Is(target error) bool
- func (e Error) MarshalJSON() ([]byte, error)
- func (e Error) Meta() meta
- func (Error) Safe() bool
- func (e *Error) Stack(skip int) *Error
- func (e Error) Translate(tr func(string, string, ...string) string) error
- func (e Error) Unwrap() error
- func (e *Error) Wrap(err error) *Error
- type ErrorHandler
Examples ¶
- Package (WriteHttpJSON)
- Package (WriteHttpJSON_clientAbortedConnectionPipe)
- Package (WriteHttpJSON_clientAbortedConnectionReset)
- Package (WriteHttpPlain)
- Package (WriteHttpPlain_clientAbortedConnectionPipe)
- Package (WriteHttpPlain_clientAbortedConnectionReset)
- Package (WriteHttpPlain_masked)
- Package (WriteHttpPlain_unmasked)
Constants ¶
View Source
const ( // internal (unspecified) error // these errors yield HTTP status 500 and hide // details unless in development environment KindInternal kind = iota // Data validation error KindInvalidData // Requested data not found KindNotFound // Stale data submitted // Internally data was already updated or is locked in another session KindStaleData // Data already exists KindDuplicateData // Data sensitivity related issue KindSensitiveData KindUnauthorized // Expecting authenticated user KindUnauthenticated // External system failure KindExternal // store error KindStore // object store (file upload/download) KindObjStore // automation error KindAutomation )
Variables ¶
This section is empty.
Functions ¶
func AddNodeStack ¶
func AddNodeStack(stack []string) mfn
Converts and attaches node.js stack to error
func IsAutomation ¶
func IsDuplicateData ¶
func IsExternal ¶
func IsInternal ¶
func IsInvalidData ¶
func IsNotFound ¶
func IsObjStore ¶
func IsSensitiveData ¶
func IsStaleData ¶
func IsUnauthenticated ¶
func IsUnauthorized ¶
func ProperlyServeHTTP ¶
ProperlyServeHTTP Prepares and encodes given error for HTTP transport, same as ServeHTTP but with proper status codes
func ServeHTTP ¶
ServeHTTP Prepares and encodes given error for HTTP transport
mask arg hides extra/debug info
Proper HTTP status codes are generally not used in the API due to compatibility issues This should be addressed in the future versions when/if we restructure the API
func ServeHTTPWithCode ¶
Serves error via
func StackTrimAtFn ¶
func StackTrimAtFn(fn string) mfn
StackTrimAtFn removes all frames after (inclusive) the (1st) function match
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func Automation ¶
func DuplicateData ¶
func InvalidData ¶
func SensitiveData ¶
func Unauthenticated ¶
func Unauthorized ¶
func (Error) MarshalJSON ¶
type ErrorHandler ¶
Click to show internal directories.
Click to hide internal directories.