Add error message when loader can't load command (#55)

And change exit code from EX_CONFIG to EX_SOFTWARE.
This commit is contained in:
Ryan Schmidt 2022-11-19 21:14:57 -06:00 committed by GitHub
parent 022d4cffe9
commit a76287876c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -957,10 +957,19 @@ int main(int argc, char **argv)
#ifdef LOADER_LOAD
uint16_t err = Loader::Native::LoadFile(command);
if (err) exit(EX_CONFIG);
if (err) {
const char *cp = ErrorName(err);
fprintf(stderr, "Unable to load command %s: ", command.c_str());
if (cp) printf("%s\n", cp);
else printf("%hd\n", err);
exit(EX_SOFTWARE);
}
#else
uint32_t address = load(command.c_str());
if (!address) exit(EX_CONFIG);
if (!address) {
fprintf(stderr, "Unable to load command %s\n", command.c_str());
exit(EX_SOFTWARE);
}
#endif
GlobalInit();