-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: replace most fatal exitOnErr calls with error returns
exitOnErr prints an error to stderr if there is any, and if fatal is true, it also stops the command via panicExit, which is recovered later in Command.Run via recoverError. In a way, this avoids a small amount of verbosity, as we use a single line rather than three to handle errors. However, it makes our error handling inconsistent and subtle, to the point that it is hard to see where a command function actually stops running. Moreover, most of the function bodies we change here already returned an error value, so it's even more confusing that a function might sometimes choose to panicExit with an error rather than return it. The behavior ends up being the same, as any call sites with error checks don't run any code before returning a non-nil error. Replace nearly all uses of exitOnErr with fatal=true with error returns. Only buildInstances remains, but that will require a larger refactor as the function and its callers do not return errors yet. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ib4dbe45e7e87b911badb57665bff77621110e1e2 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194537 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Noam Dolovich <[email protected]>
- Loading branch information
Showing
8 changed files
with
89 additions
and
61 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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