Refactor OS exit code to be EXIT_SUCCESS by default
- `Main::setup` early exits (failure or `--help`/`--version`) now consistently return `EXIT_FAILURE` or `EXIT_SUCCESS` on all platforms, instead of 255 on some and a Godot Error code on others. - `Main::start` now returns the exit code, simplifying the handling of early failures. - `Main::iteration` needs to explicit set the exit code in OS if it errors out. - Web and iOS now properly return `OS::get_exit_code()` instead of 0.
This commit is contained in:
@ -72,18 +72,19 @@ int main(int argc, char *argv[]) {
|
||||
char *ret = getcwd(cwd, PATH_MAX);
|
||||
|
||||
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
|
||||
|
||||
if (err != OK) {
|
||||
free(cwd);
|
||||
|
||||
if (err == ERR_HELP) { // Returned by --help and --version, so success.
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return 255;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (Main::start()) {
|
||||
os.set_exit_code(EXIT_SUCCESS);
|
||||
os.run(); // it is actually the OS that decides how to run
|
||||
if (Main::start() == EXIT_SUCCESS) {
|
||||
os.run();
|
||||
} else {
|
||||
os.set_exit_code(EXIT_FAILURE);
|
||||
}
|
||||
Main::cleanup();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user