| 1 | package errorsx |
| 2 | |
| 3 | // String representing an error, useful for declaring string constants as errors. |
| 4 | type String string |
| 5 | |
| 6 | func (t String) Error() string { |
| 7 | return string(t) |
| 8 | } |
| 9 | |
| 10 | // Is reports whether String matches with the target error |
| 11 | func (t String) Is(target error) bool { |
| 12 | if target == nil { |
| 13 | return false |
| 14 | } |
| 15 | |
| 16 | return t.Error() == target.Error() |
| 17 | } |