Add error handler for non-zero exit codes

A callback function will receive an `ExitCodeError`, which contains the
return value and the final contents of stdout and stderr.