-
Notifications
You must be signed in to change notification settings - Fork 6
Errors
All tasks need to return an error
or nil
. The default case of an error is that gotaskr will abort and do not run additional tasks.
If a task gets into a panic
, gotaskr will catch it and gracefully abort in any case.
There are ways to configure how errors should be handled.
When an error should not abort, you can use the ContinueOnError
method while defining tasks. In that case, gotaskr will just continue to run the other tasks and just report the error but succeed if no other error occurs.
Example:
gotaskr.Task("Slack-Notify", notifyFunc).ContinueOnError()
When an error should be deferred to the very end of the execution, you can us the DeferOnError
method while defining tasks. In that case, gotaskr will continue running and at the end exit with an error code.
A typical example would be for tests results. There the test method usually returns an error but you might want to upload the test results first, before failing.
Example:
gotaskr.Task("Test", testFunc).Then("UploadTestResults").DeferOnError()