-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds custom error codes #236
Open
nkakouros
wants to merge
16
commits into
mbland:main
Choose a base branch
from
nkakouros-forks:return_codes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
nkakouros
changed the title
Adds custom error codes to go-core.bash
Adds custom error codes
Jan 19, 2018
I have now finished work on this. Waiting for feedback. |
Is there interest in this PR? Would it be worth spending more time on this? |
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.
contribution under the same terms as this project's license, and
that I have the right to license my contribution under those terms.
cc: @mbland
This PR is an approach to introducing custom exit codes. This is in relation to #234.
Some notes
return x
commands that are used by functions to signal either an error or one of two or more possible outcomes. There are alsoexit x
commands to stop script execution. I rewrite both of these.return
,exit
,return 0
orexit 0
commands are rewritten asreturn "$_GO_EC_OK"
, etc, where the return code will not be but 0. Although adding nothing in functionality, this is done to be consistent.@go()
may return with$_GO_EC_CONFIG
or$_GO_EC_USAGE
. If@go()
were to be called by another function, eg@go.for_lack_of_better_example()
then it would be called like this:return
will return with the return code of@go.another_func
. Assuming that, as a go function,@go.another_func
will return using the custom codes, no change is performed in the code.is rewritten to
Here,
printf
may exit with2
if there are wrong arguments used and1
for other errors._GO_EC_GENERR+1
corresponds to_GO_EC_EXT1
and_GO_EC_GENERR+2
to_GO_EC_EXT2
.But, for instance:
is left as is, since echo will fail only when a write error occurs, which would mean bigger problems anyway.
bats_restore_shell_options
are left as is. Should these be changed as well?