mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-23 21:32: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
|
#pragma once
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
|
|
||||||
|
/// Type of thrown fatal error.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FatalType_ErrorReportAndErrorScreen = 0,
|
FatalType_ErrorReportAndErrorScreen = 0,
|
||||||
FatalType_ErrorReport = 1,
|
FatalType_ErrorReport = 1,
|
||||||
@ -24,6 +25,6 @@ void NORETURN fatalSimple(Result err);
|
|||||||
* @brief Triggers a system fatal error with a custom FatalType.
|
* @brief Triggers a system fatal error with a custom FatalType.
|
||||||
* @param err[in] Result code to throw.
|
* @param err[in] Result code to throw.
|
||||||
* @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 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) {
|
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()) {
|
||||||
@ -49,7 +51,14 @@ void NORETURN fatalWithType(Result err, FatalType type) {
|
|||||||
ipcDispatch(srv);
|
ipcDispatch(srv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((void(*)())0xBADC0DE)();
|
switch (type) {
|
||||||
__builtin_unreachable();
|
case FatalType_ErrorReport:
|
||||||
|
break;
|
||||||
|
case FatalType_ErrorReportAndErrorScreen:
|
||||||
|
case FatalType_ErrorScreen:
|
||||||
|
default:
|
||||||
|
svcExitProcess();
|
||||||
|
__builtin_unreachable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user