Skip to content

Commit 7a41650

Browse files
committed
fire off report_error() and send_program_notification() on unrecoverable errors.
1 parent 3a65dee commit 7a41650

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "Common/Cpp/Exceptions.h"
88
#include "Common/Cpp/Concurrency/SpinPause.h"
99
#include "CommonFramework/GlobalSettingsPanel.h"
10+
#include "CommonFramework/ErrorReports/ErrorReports.h"
1011
#include "CommonFramework/Exceptions/ProgramFinishedException.h"
1112
#include "CommonFramework/Options/Environment/SleepSuppressOption.h"
1213
#include "CommonFramework/Options/Environment/PerformanceOptions.h"
@@ -91,12 +92,36 @@ void SingleSwitchProgramSession::run_program_instance(SingleSwitchProgramEnviron
9192
try{
9293
m_option.instance().program(env, context);
9394
context.wait_for_all_requests();
94-
}catch (...){
95+
}catch (Exception& e){
9596
try{
9697
env.console.controller().cancel_all_commands();
9798
}catch (...){}
9899
std::lock_guard<std::mutex> lg(program_lock());
99100
m_scope.store(nullptr, std::memory_order_release);
101+
102+
std::vector<std::pair<std::string, std::string>> embeds;
103+
if (!e.message().empty()){
104+
embeds.emplace_back(std::pair<std::string, std::string>("Message:", e.message()));
105+
}
106+
std::string title = "UNRECOVERABLE ERROR: ";
107+
title.push_back(*e.name());
108+
PokemonAutomation::report_error(
109+
&env.logger(),
110+
env.program_info(),
111+
title,
112+
embeds,
113+
ImageViewRGB32(),
114+
nullptr
115+
);
116+
117+
send_program_notification(
118+
env, m_option.instance().NOTIFICATION_ERROR_FATAL,
119+
COLOR_RED,
120+
title,
121+
std::move(embeds), "",
122+
ImageViewRGB32()
123+
);
124+
100125
throw;
101126
}
102127
#else

0 commit comments

Comments
 (0)