Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PanicIf ¶
PanicIf will panic with a custom error if a condition is true.
In fakes and tests, it is often desirable to panic when some precondition is violated to provide a loud indication that something wasn't set correctly. PanicIf allows for panicking in those situations without having to introduce uncovered conditional code and/or adding tests to cover those situations.
This should be limited to test code and fakes. The code for the actual binary should use proper error handling.
func PanicOnError ¶
func PanicOnError(err error)
PanicOnError will panic if err is not nil.
Specific error types will have additional information added to the panic e.g. the stderr of a failed process will be included in the panic in the case of *exec.ExitError.
In fakes and tests, it is often desirable to panic rather than returning an error (e.g. the fake data is in an inconsistent state or a function should always succeed) because the situation isn't one where the errors should be handled. PanicOnError allows for panicking in those situations without having to introduce uncovered conditional code and/or adding tests to cover those situations.
This should be limited to test code and fakes. The code for the actual binary should use proper error handling.
Types ¶
This section is empty.