-
Notifications
You must be signed in to change notification settings - Fork 2
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
Throw error instead of exiting silently #142
Comments
Well it is not silent, it prints a very clear message why it exits early. Last year students complained when they saw stacktraces, so we switched to messages only :P Should we switch to stderr and return a non-zero exit code? |
Yeah, Stacktraces do not really help there... also keep in mind that the engine is not inside docker. The Console.Writelines plop directly into your shell, it is really hard to miss. |
What? Why did they complain about stack traces? That's normal in IT. 😂 It is displaying the same message just with more information and in Visual Studio it even opens a popup that something went wrong instead of just exiting silently. I get it that for newcomers it may make things more complicated, but programming is based on standards and these should be adhered to. |
To be fair, that's normal for crappy programs, but not the general state of IT. Imagine linux utils like |
But these tools do exit with a non-zero exit code |
Changing that should be easy, just |
We could also wrap the program into an ExceptionHandler as you already do it in the lines below. This way throughout the program you could still use Exceptions and then write a nice output with the Release build. (while keeping the stack traces during development) catch (Exception e)
{
#if (DEBUG)
throw e;
#else
Console.WriteLine(e.Message);
return 1;
#endif
}
finally
{
mutex?.Close();
}
return 0; |
But you will never actually need a Stacktrace in this particular case. It is just stupid to make it return a useless stacktrace instead of a single message to exactly tell you what the problem is. As Trolldemorted said, you won't want cat to print a stacktrace as well when the file not exists. And bloating the code with useless #IF wont do any good. |
I agree that you don't need an actual Stacktrace in the case I provided and also for running it in release. Just to name an example where it actually hurts: EnoEngine/EnoEngine/Program.cs Lines 66 to 70 in 950a3da
Here the child Exception is swallowed and will never be displayed. If the service for a checker is not reachable the only message displayed will be Configuration is invalid. , whereas with proper Exception:![]() In order to not mix up both, I added the general case in the upper comment. |
I don't really get what you are trying to do. The code you referenced belongs to the checking of the config file. The stacktrace there does not contain any useful information, and the exception message is already printed. The HTTPRequestException you posted is something else entirely. The case when a checker is not reachable should also not throw an Exception, but should exit with the appropriate Error or continue for testing, as discussed in #144. What would an exception with a stacktrace into the HTTPClient actually help anyone, when it is as simple as a connection being refused? |
This issue is about the general practice of not throwing errors but just silently exiting (during development). I tried to run the Engine but kept on running into issues. Until #144 is implemented this is still an issue and will be in the future for any other nested Exception.
Instead of just seeing a |
The issue is not the service being unreachable, not even the checker being unreachable. The issue is exactly what is printed - the Config is invalid. |
…errypicked from DanielHabenicht) Closes #142
…errypicked from DanielHabenicht) Closes #142
…errypicked from DanielHabenicht) Closes #142
EnoEngine/EnoEngine/Program.cs
Lines 34 to 38 in 950a3da
is just one of example of silently exiting.
It should throw errors instead:
The text was updated successfully, but these errors were encountered: