Fatal: Only exit process if required, exit cleanly.

This commit is contained in:
Michael Scire 2018-06-25 22:25:47 -06:00
parent aee9ba4706
commit 5754be9ff9
2 changed files with 14 additions and 5 deletions

View File

@ -26,4 +26,4 @@ void NORETURN fatalSimple(Result err);
* @param err[in] Type of fatal error to throw.
* @note This function does not return.
*/
void NORETURN fatalWithType(Result err, FatalType type);
void fatalWithType(Result err, FatalType type);

View File

@ -10,9 +10,11 @@
void NORETURN fatalSimple(Result err) {
/* By default, do not generate an error report. */
fatalWithType(err, FatalType_ErrorScreen);
svcExitProcess();
__builtin_unreachable();
}
void NORETURN fatalWithType(Result err, FatalType type) {
void fatalWithType(Result err, FatalType type) {
Result rc = 0;
if (detectDebugger()) {
@ -49,7 +51,14 @@ void NORETURN fatalWithType(Result err, FatalType type) {
ipcDispatch(srv);
}
}
((void(*)())0xBADC0DE)();
__builtin_unreachable();
switch (type) {
case FatalType_ErrorReport:
break;
case FatalType_ErrorReportAndErrorScreen:
case FatalType_ErrorScreen:
default:
svcExitProcess();
__builtin_unreachable();
}
}