Skip to content

Commit a07d936

Browse files
committed
fire off send_fatal_notification() on unrecoverable errors for ScreenshotException.
1 parent 3a65dee commit a07d936

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,41 @@ void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotifi
111111
);
112112
}
113113

114+
void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const{
115+
std::vector<std::pair<std::string, std::string>> embeds;
116+
if (!m_message.empty()){
117+
embeds.emplace_back(std::pair<std::string, std::string>("Message:", m_message));
118+
}
119+
120+
std::string title = "Fatal Error: ";
121+
title.append(name());
122+
123+
if (m_send_error_report == ErrorReport::SEND_ERROR_REPORT){
124+
report_error(
125+
&env.logger(),
126+
env.program_info(),
127+
title,
128+
embeds,
129+
screenshot_view(),
130+
m_stream ? &m_stream->history() : nullptr
131+
);
132+
}
133+
134+
EventNotificationOption fatal_notification = EventNotificationOption(
135+
"Program Error (Fatal)",
136+
true, true,
137+
ImageAttachmentMode::JPG,
138+
{"Notifs"}
139+
);
140+
141+
send_program_notification(
142+
env, fatal_notification,
143+
color(),
144+
name(),
145+
std::move(embeds), "",
146+
screenshot_view()
147+
);
148+
}
114149

115150

116151

SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class ScreenshotException : public Exception{
7272

7373
virtual Color color() const{ return COLOR_RED; }
7474
virtual void send_notification(ProgramEnvironment& env, EventNotificationOption& notification) const;
75+
void send_fatal_notification(ProgramEnvironment& env) const;
7576

7677
public:
7778
ErrorReport m_send_error_report;

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void MultiSwitchProgramSession::internal_run_program(){
233233
message = e.name();
234234
}
235235
report_error(message);
236-
e.send_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL);
236+
e.send_fatal_notification(env);
237237
}catch (Exception& e){
238238
logger().log("Program stopped with an exception!", COLOR_RED);
239239
env.add_overlay_log_to_all_consoles("- Program Error -", COLOR_RED);

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void SingleSwitchProgramSession::internal_run_program(){
194194
message = e.name();
195195
}
196196
report_error(message);
197-
e.send_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL);
197+
e.send_fatal_notification(env);
198198
}catch (Exception& e){
199199
logger().log("Program stopped with an exception!", COLOR_RED);
200200
env.console.overlay().add_log("- Program Error -", COLOR_RED);

SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,6 @@ bool EggAutonomous::handle_recoverable_error(
767767
auto& stats = env.current_stats<EggAutonomous_Descriptor::Stats>();
768768
stats.m_errors++;
769769
env.update_stats();
770-
e.send_notification(env, notification);
771770

772771
if (SAVE_DEBUG_VIDEO){
773772
// Take a video to give more context for debugging
@@ -797,6 +796,7 @@ bool EggAutonomous::handle_recoverable_error(
797796
env.console
798797
);
799798
}
799+
e.send_notification(env, notification);
800800

801801
env.log("Reset game to handle recoverable error");
802802
reset_game(env.program_info(), env.console, context);

0 commit comments

Comments
 (0)