Commit 91a8ed8
Ronen Hilewicz
Fix formatting of inner errors
The Go convention is for errors to be formatted from outermost
to innermost separated by colons.
However, `AsertoError` prints the inner error messages _before_
the outer.
For example, consider the following snippet:
```go
// An AsertoError
ErrInvalidPermission := cerr.NewAsertoError("E20008", codes.InvalidArgument, http.StatusBadRequest, "invalid permission")
// Regular Go errors
ErrInvalidIdentifier := errors.New("invalid identifier")
innerError := errors.Wrap(ErrInvalidIdentifier, "'GET'")
// Final error
err := ErrInvalidPermission.Err(innerError).Msg("'resource:can_read'")
fmt.Println(err)
```
We expect the output to be:
```
E20008 invalid permission: 'resource:can_read': 'GET': invalid identifier
```
But instead we get:
```
E20008 invalid permission: 'GET': invalid identifier: 'resource:can_read'
```
This change to the `Error()` function fixes the formatting.1 parent 971bab0 commit 91a8ed8
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
0 commit comments