Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make expression package return ErrExpressionResolution when res…
…olution fails (#2292) * make returned error a ErrExpressionResolution * simplify error messages when expression resolution fails * make sure all errors when unwrapped, don't start with "resolution error:"
- Loading branch information
1 parent
8741411
commit 4815398
Showing
5 changed files
with
124 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package expression | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
var ErrExpressionResolution error = errors.New("resolution error") | ||
|
||
type ResolutionError struct { | ||
innerErr error | ||
} | ||
|
||
func (e *ResolutionError) Error() string { | ||
return fmt.Sprintf("%s: %s", ErrExpressionResolution.Error(), e.innerErr.Error()) | ||
} | ||
|
||
func (e *ResolutionError) Is(target error) bool { | ||
// all Resolution errors are ErrExpressionResolution | ||
if errors.Is(target, ErrExpressionResolution) { | ||
return true | ||
} | ||
|
||
return errors.Is(e.innerErr, target) | ||
} | ||
|
||
func (e *ResolutionError) Unwrap() error { | ||
return e.innerErr | ||
} | ||
|
||
func resolutionError(innerErr error) error { | ||
return &ResolutionError{innerErr: innerErr} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters