fpw / avitab

X-Plane plugin that displays a tablet to aid VR usage
GNU Affero General Public License v3.0
299 stars 58 forks source link

Show exceptions early when starting AviTab-standalone #165

Closed cyberang3l closed 9 months ago

cyberang3l commented 10 months ago

After compiling the program, it was silently failing with a 0 exit code in the shell. I had to use strace to figure out that it was not able to find the config.json file. In such scenario, a visible exception should be thrown.

Although the Config class throws an exception if the configStream cannot be constructed, this exception is now shown to the user as the logger::error that is used to show the error, expects the config to be properly instantiated first (cyclic dependency).

This commit uses std::cerr in the catch block of the main function, to show all the errors that occur and get caught even if the configuration is not properly loaded. Moreover, if the catch block is triggered, main (and consequently the entire program) now returns 1, which is the correct exit shell code - when an error occurs the exit code should be non-zero.