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

Catch an exception and exit if cannot load config in standalone mode #179

Closed cyberang3l closed 9 months ago

cyberang3l commented 9 months ago

Print an error with std::cerr as the logger hasn't been loaded yet (it depends on the config.json being present). Without this, we get a silent failure with an incorrect 0 exit code (that indicates success) instead of 1, that I was only able to figure out with strace.

Note that this is only fixing the Standalone app; The same bug exists in the plugins. The following lines will currently cause the same behaviour, but I don't know what will the behaviour be if we add an "exit(1)" in the plugins (will the entire X-Plane exit in this case?), and even if we do, we probably don't want to use std::cerr to indicate that we cannot find the config.json, but a function that prints something that the user can see in the simulator somehow.

https://github.com/fpw/avitab/blob/2228fa8c12f630a87876faaf3cce887268ef303d/src/Plugin.cpp#L42

https://github.com/fpw/avitab/blob/2228fa8c12f630a87876faaf3cce887268ef303d/src/MsfsAddon.cpp#L32

fpw commented 9 months ago

Thanks!