Open
Conversation
This resolves rahult#10. - Raise an exception when a system command fails with a non-zero exception. (This could be a custom exception.) - bin/karo should return a non-zero exit status when an exception is rescued. - Error messages should be printed on STDERR, not STDOUT. - Inform the user when a system interrupt is triggered on STDERR; this emulates the behaviour of most other UNIX commands.
Commands that fail should return a non-zero exit status.
Was receiving an error: ``` bin/karo:11:in `rescue in <top (required)>': unexpected return (LocalJumpError) ``` Have changed `return 1` to `exit 1`. The purpose of this line is to exit the program with a non-zero exit status if an unhandled exception is encountered.
This change means the `rescue` is now only for `StandardError` and its subclasses. For more info about why this change is necessary, see: [This SO answer][1] [1]: http://stackoverflow.com/a/10048406/848668
The backtrace has been added to the STDERR output so that the user can identify any issues that may have arisen in the karo code base. A suggested improvement would be to create a custom `KaroException` error class that can be used to handle any known exception cases within the karo codebase.
After running a command, `$?.exitstatus` will be set to the exit status of the last executed process. If the process finishes without errors,`$?.exitstatus` will be `0`. For all other values, we will raise an exception.
Fix karo errors
Owner
|
Nice work @br3nt, can we squash the commits into one before merging? |
Author
|
@rahult, looks like you can do it at the time of merging... https://help.github.com/articles/about-pull-request-merges/ |
Owner
|
Thanks @br3nt, this branch has conflicts based on a previous pull request I merged so cannot do it automatically 😉 (would have been nice) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per description of pull request #11, this has the following features:
bin/karoshould return a non-zero exit status when an exception is rescued.Additionally, my pull request adds:
unexpected return (LocalJumpError)errorException. For why this change is necessary see this SO answernilbut should be checking for non-zero value.