Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Return non-zero exit code for unhandled exceptions #910

Conversation

Bouke
Copy link
Contributor

@Bouke Bouke commented Dec 13, 2019

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

feature

⤵️ What is the current behavior?

Currently when an exception is thrown besides CommandParsingException, the exit code of the tool will be 0 (no error). This means that in CI builds on a schedule, you won't get build failures if something is wrong (#904).

C:\Program Files\dotnet\dotnet.exe (process 13168) exited with code 0.

🆕 What is the new behavior (if this is a feature change)?

With this change, a non-zero exit code is returned, which would then fail the build and cause alarm bells to ring.

C:\Program Files\dotnet\dotnet.exe (process 13168) exited with code 2.

💥 Does this PR introduce a breaking change?

Maybe. So other tools relying on a zero exit code even when errors happen, would need a change. I think this is desirable.

🐛 Recommendations for testing

Nuget.config:

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear/>
  </packageSources>
</configuration>

📝 Links to relevant issues/docs

#904

🤔 Checklist before submitting

  • All projects build
  • Relevant documentation was updated

@Bouke Bouke force-pushed the non-zero-exit-code-on-unhandled-exception branch from a773c17 to 59c8616 Compare December 13, 2019 11:52
@MarcBruins
Copy link
Member

MarcBruins commented Jan 24, 2020

Mm the returning of a code other then 0 is definitely a good idea. I don't like the enum status codes and the additional cast that comes with it though. Can't we just return the integer value?

@Bouke
Copy link
Contributor Author

Bouke commented Jan 24, 2020

The reason for using enums is to be clear about which error codes can be returned, and a single location of defining those return codes. Using different error codes allows scripts to behave differently depending on the error code, log error code etc. The MVP here would be to return non-zero on errors, so dropping the enum is fine by me.

@AnthonySteele AnthonySteele merged commit b1f2ea6 into NuKeeperDotNet:master Feb 12, 2020
@Bouke Bouke deleted the non-zero-exit-code-on-unhandled-exception branch March 25, 2020 19:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants