forked from d2iq-archive/mesos-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request d2iq-archive#352 from mesosphere/mesos-dns-223
Move util.IgnoreError to errorutil.IgnoreErrror
Access has been restricted
You have triggered a rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
Showing
5 changed files
with
34 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package errorutil | ||
|
||
// ErrorFunction A function definition that returns an error | ||
// to be passed to the Ignore or Panic error handler | ||
type ErrorFunction func() error | ||
|
||
// Ignore Calls an ErrorFunction, and ignores the result. | ||
// This allows us to be more explicit when there is no error | ||
// handling to be done, for example in defers | ||
func Ignore(f ErrorFunction) { | ||
_ = f() | ||
} |
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,20 @@ | ||
package errorutil | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
) | ||
|
||
func returnsError() error { | ||
return errors.New("test") | ||
} | ||
func TestIgnoreHandler(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
t.Fatal("IgnoreHandler did not ignore Error") | ||
} | ||
}() | ||
|
||
Ignore(returnsError) | ||
|
||
} |
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