github.com/influx6/npkg@v0.8.8/nerror/readme.md (about)

     1  Errors
     2  ---------
     3  
     4  Errors provides a package for wrapping go based nerror with location of return site.
     5  
     6  
     7  ## Install
     8  
     9  ```bash
    10  go get -v github.com/influx6/npkg/nerror
    11  ```
    12  
    13  ## Usage
    14  
    15  1. Create new nerror
    16  
    17  
    18  ```go
    19  newBadErr = nerror.New("failed connection: %s", "10.9.1.0")
    20  ```
    21  
    22  2. Create new nerror with stacktrace
    23  
    24  
    25  ```go
    26  newBadErr = nerror.Stacked("failed connection: %s", "10.9.1.0")
    27  ```
    28  
    29  3. Wrap existing error
    30  
    31  
    32  ```go
    33  newBadErr = nerror.Wrap(BadErr, "something bad happened here")
    34  ```
    35  
    36  4. Wrap existing error with stacktrace
    37  
    38  
    39  ```go
    40  newBadErr = nerror.WrapStack(BadErr, "something bad happened here")
    41  ```
    42  
    43  5. Add Stack to package's error type without stack trace.
    44  
    45  
    46  ```go
    47  newBadErr = nerror.StackIt(BadErr)
    48  ```