-
Notifications
You must be signed in to change notification settings - Fork 3
Make NoArtifactError.Error() nil-safe
#67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,6 +170,9 @@ type NoArtifactError struct { | |
| } | ||
|
|
||
| func (n *NoArtifactError) Error() string { | ||
| if n == nil || n.err == nil { | ||
| return "no artifact found" | ||
| } | ||
| return fmt.Sprintf("no artifact found: %s", n.err.Error()) | ||
|
Comment on lines
172
to
176
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change adds a new behavior path (
n == nilorn.err == nil) but there isn't a unit test asserting that(&NoArtifactError{}).Error()returns the expected message and does not panic. Adding a small regression test would prevent future reintroductions of the nil-deref.