gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

README.md (2124B)


      1 go-errors/errors
      2 ================
      3 
      4 [![Build Status](https://travis-ci.org/go-errors/errors.svg?branch=master)](https://travis-ci.org/go-errors/errors)
      5 
      6 Package errors adds stacktrace support to errors in go.
      7 
      8 This is particularly useful when you want to understand the state of execution
      9 when an error was returned unexpectedly.
     10 
     11 It provides the type \*Error which implements the standard golang error
     12 interface, so you can use this library interchangably with code that is
     13 expecting a normal error return.
     14 
     15 Usage
     16 -----
     17 
     18 Full documentation is available on
     19 [godoc](https://godoc.org/github.com/go-errors/errors), but here's a simple
     20 example:
     21 
     22 ```go
     23 package crashy
     24 
     25 import "github.com/go-errors/errors"
     26 
     27 var Crashed = errors.Errorf("oh dear")
     28 
     29 func Crash() error {
     30     return errors.New(Crashed)
     31 }
     32 ```
     33 
     34 This can be called as follows:
     35 
     36 ```go
     37 package main
     38 
     39 import (
     40     "crashy"
     41     "fmt"
     42     "github.com/go-errors/errors"
     43 )
     44 
     45 func main() {
     46     err := crashy.Crash()
     47     if err != nil {
     48         if errors.Is(err, crashy.Crashed) {
     49             fmt.Println(err.(*errors.Error).ErrorStack())
     50         } else {
     51             panic(err)
     52         }
     53     }
     54 }
     55 ```
     56 
     57 Meta-fu
     58 -------
     59 
     60 This package was original written to allow reporting to
     61 [Bugsnag](https://bugsnag.com/) from
     62 [bugsnag-go](https://github.com/bugsnag/bugsnag-go), but after I found similar
     63 packages by Facebook and Dropbox, it was moved to one canonical location so
     64 everyone can benefit.
     65 
     66 This package is licensed under the MIT license, see LICENSE.MIT for details.
     67 
     68 
     69 ## Changelog
     70 * v1.1.0 updated to use go1.13's standard-library errors.Is method instead of == in errors.Is
     71 * v1.2.0 added `errors.As` from the standard library.
     72 * v1.3.0 *BREAKING* updated error methods to return `error` instead of `*Error`.
     73 >  Code that needs access to the underlying `*Error` can use the new errors.AsError(e)
     74 > ```
     75 >   // before
     76 >   errors.New(err).ErrorStack()
     77 >   // after
     78 >.  errors.AsError(errors.Wrap(err)).ErrorStack()
     79 > ```
     80 * v1.4.0 *BREAKING* v1.4.0 reverted all changes from v1.3.0 and is identical to v1.2.0
     81 * v1.4.1 no code change, but now without an unnecessary cover.out file.