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. * @param err[in] Type of fatal error to throw.
* @note This function does not return. * @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) { void NORETURN fatalSimple(Result err) {
/* By default, do not generate an error report. */ /* By default, do not generate an error report. */
fatalWithType(err, FatalType_ErrorScreen); fatalWithType(err, FatalType_ErrorScreen);
svcExitProcess();
__builtin_unreachable();
} }
void NORETURN fatalWithType(Result err, FatalType type) { void fatalWithType(Result err, FatalType type) {
Result rc = 0; Result rc = 0;
if (detectDebugger()) { if (detectDebugger()) {
@ -50,6 +52,13 @@ void NORETURN fatalWithType(Result err, FatalType type) {
} }
} }
((void(*)())0xBADC0DE)(); switch (type) {
case FatalType_ErrorReport:
break;
case FatalType_ErrorReportAndErrorScreen:
case FatalType_ErrorScreen:
default:
svcExitProcess();
__builtin_unreachable(); __builtin_unreachable();
} }
}