mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-23 05:12:39 +02:00
Fatal: Only exit process if required, exit cleanly. (#127)
* Fatal: Only exit process if required, exit cleanly.
This commit is contained in:
parent
a9c0b213ff
commit
97b295acbc
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
|
||||
/// Type of thrown fatal error.
|
||||
typedef enum {
|
||||
FatalType_ErrorReportAndErrorScreen = 0,
|
||||
FatalType_ErrorReport = 1,
|
||||
@ -24,6 +25,6 @@ void NORETURN fatalSimple(Result err);
|
||||
* @brief Triggers a system fatal error with a custom FatalType.
|
||||
* @param err[in] Result code to throw.
|
||||
* @param err[in] Type of fatal error to throw.
|
||||
* @note This function does not return.
|
||||
* @note This function may not return, depending on \ref FatalType.
|
||||
*/
|
||||
void NORETURN fatalWithType(Result err, FatalType type);
|
||||
void fatalWithType(Result err, FatalType type);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user