From a07d9361124347c215e0e8ab317c5562ebfe65df Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 24 Aug 2025 18:51:13 -0700 Subject: [PATCH 1/5] fire off send_fatal_notification() on unrecoverable errors for ScreenshotException. --- .../Exceptions/ScreenshotException.cpp | 35 +++++++++++++++++++ .../Exceptions/ScreenshotException.h | 1 + ...ntendoSwitch_MultiSwitchProgramSession.cpp | 2 +- ...tendoSwitch_SingleSwitchProgramSession.cpp | 2 +- .../Programs/Eggs/PokemonSV_EggAutonomous.cpp | 2 +- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp index eb85bfe12b..24a285c926 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp @@ -111,6 +111,41 @@ void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotifi ); } +void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const{ + std::vector> embeds; + if (!m_message.empty()){ + embeds.emplace_back(std::pair("Message:", m_message)); + } + + std::string title = "Fatal Error: "; + title.append(name()); + + if (m_send_error_report == ErrorReport::SEND_ERROR_REPORT){ + report_error( + &env.logger(), + env.program_info(), + title, + embeds, + screenshot_view(), + m_stream ? &m_stream->history() : nullptr + ); + } + + EventNotificationOption fatal_notification = EventNotificationOption( + "Program Error (Fatal)", + true, true, + ImageAttachmentMode::JPG, + {"Notifs"} + ); + + send_program_notification( + env, fatal_notification, + color(), + name(), + std::move(embeds), "", + screenshot_view() + ); +} diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h index e10a8c313f..891f9f07b9 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h @@ -72,6 +72,7 @@ class ScreenshotException : public Exception{ virtual Color color() const{ return COLOR_RED; } virtual void send_notification(ProgramEnvironment& env, EventNotificationOption& notification) const; + void send_fatal_notification(ProgramEnvironment& env) const; public: ErrorReport m_send_error_report; diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp index 161d18bcf7..0ac85e319b 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp @@ -233,7 +233,7 @@ void MultiSwitchProgramSession::internal_run_program(){ message = e.name(); } report_error(message); - e.send_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL); + e.send_fatal_notification(env); }catch (Exception& e){ logger().log("Program stopped with an exception!", COLOR_RED); env.add_overlay_log_to_all_consoles("- Program Error -", COLOR_RED); diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp index 4bc79eb428..1fd42b4f53 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp @@ -194,7 +194,7 @@ void SingleSwitchProgramSession::internal_run_program(){ message = e.name(); } report_error(message); - e.send_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL); + e.send_fatal_notification(env); }catch (Exception& e){ logger().log("Program stopped with an exception!", COLOR_RED); env.console.overlay().add_log("- Program Error -", COLOR_RED); diff --git a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp index f335ff5312..384d8339ed 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp @@ -767,7 +767,6 @@ bool EggAutonomous::handle_recoverable_error( auto& stats = env.current_stats(); stats.m_errors++; env.update_stats(); - e.send_notification(env, notification); if (SAVE_DEBUG_VIDEO){ // Take a video to give more context for debugging @@ -797,6 +796,7 @@ bool EggAutonomous::handle_recoverable_error( env.console ); } + e.send_notification(env, notification); env.log("Reset game to handle recoverable error"); reset_game(env.program_info(), env.console, context); From cd31edc627b8ed5901146ea66bcd605326919b53 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 24 Aug 2025 19:23:01 -0700 Subject: [PATCH 2/5] add send_recoverable_notification() --- .../Exceptions/ScreenshotException.cpp | 43 +++++++------------ .../Exceptions/ScreenshotException.h | 3 +- .../Programs/Eggs/PokemonSV_EggAutonomous.cpp | 2 +- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp index 24a285c926..2d2c8dd3b1 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp @@ -85,17 +85,20 @@ std::shared_ptr ScreenshotException::screenshot() const{ } -void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotificationOption& notification) const{ +void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotificationOption& notification, const std::string& title_prefix) const{ std::vector> embeds; if (!m_message.empty()){ embeds.emplace_back(std::pair("Message:", m_message)); } + std::string title = title_prefix; + title.append(name()); + if (m_send_error_report == ErrorReport::SEND_ERROR_REPORT){ report_error( &env.logger(), env.program_info(), - name(), + title, embeds, screenshot_view(), m_stream ? &m_stream->history() : nullptr @@ -111,26 +114,18 @@ void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotifi ); } -void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const{ - std::vector> embeds; - if (!m_message.empty()){ - embeds.emplace_back(std::pair("Message:", m_message)); - } - - std::string title = "Fatal Error: "; - title.append(name()); +void ScreenshotException::send_recoverable_notification(ProgramEnvironment& env) const{ + EventNotificationOption recoverable_notification = EventNotificationOption( + "Program Error (Recoverable)", + true, true, + ImageAttachmentMode::JPG, + {"Notifs"} + ); - if (m_send_error_report == ErrorReport::SEND_ERROR_REPORT){ - report_error( - &env.logger(), - env.program_info(), - title, - embeds, - screenshot_view(), - m_stream ? &m_stream->history() : nullptr - ); - } + send_notification(env, recoverable_notification, "Recoverable Error: "); +} +void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const{ EventNotificationOption fatal_notification = EventNotificationOption( "Program Error (Fatal)", true, true, @@ -138,13 +133,7 @@ void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const {"Notifs"} ); - send_program_notification( - env, fatal_notification, - color(), - name(), - std::move(embeds), "", - screenshot_view() - ); + send_notification(env, fatal_notification, "Recoverable Error: "); } diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h index 891f9f07b9..8a8b049cdd 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h @@ -71,7 +71,8 @@ class ScreenshotException : public Exception{ std::shared_ptr screenshot() const; virtual Color color() const{ return COLOR_RED; } - virtual void send_notification(ProgramEnvironment& env, EventNotificationOption& notification) const; + virtual void send_notification(ProgramEnvironment& env, EventNotificationOption& notification, const std::string& title_prefix = "") const; + void send_recoverable_notification(ProgramEnvironment& env) const; void send_fatal_notification(ProgramEnvironment& env) const; public: diff --git a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp index 384d8339ed..c980adfb82 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp @@ -796,7 +796,7 @@ bool EggAutonomous::handle_recoverable_error( env.console ); } - e.send_notification(env, notification); + e.send_recoverable_notification(env); env.log("Reset game to handle recoverable error"); reset_game(env.program_info(), env.console, context); From afbeb1a7946a6c3af27cb212abfe22a769eb38d3 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 24 Aug 2025 19:30:44 -0700 Subject: [PATCH 3/5] fix typo --- .../Source/CommonFramework/Exceptions/ScreenshotException.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp index 2d2c8dd3b1..d4c9acb327 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp @@ -133,7 +133,7 @@ void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const {"Notifs"} ); - send_notification(env, fatal_notification, "Recoverable Error: "); + send_notification(env, fatal_notification, "Fatal Error: "); } From 5c1a6eaabb20fcdedee8a053f8f65e9973782b5e Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 25 Aug 2025 13:09:23 -0700 Subject: [PATCH 4/5] minor change --- .../Source/CommonFramework/Exceptions/ScreenshotException.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp index d4c9acb327..e5dc9c83d8 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp @@ -122,7 +122,7 @@ void ScreenshotException::send_recoverable_notification(ProgramEnvironment& env) {"Notifs"} ); - send_notification(env, recoverable_notification, "Recoverable Error: "); + send_notification(env, recoverable_notification, "Recoverable: "); } void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const{ @@ -133,7 +133,7 @@ void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const {"Notifs"} ); - send_notification(env, fatal_notification, "Fatal Error: "); + send_notification(env, fatal_notification, "Fatal: "); } From 682a9ee40677c5287aa58b9c30efcbe6beceb6e8 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 25 Aug 2025 23:09:51 -0700 Subject: [PATCH 5/5] update title for send_program_notification() --- .../Source/CommonFramework/Exceptions/ScreenshotException.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp index e5dc9c83d8..35bf7bd6b9 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp @@ -108,7 +108,7 @@ void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotifi send_program_notification( env, notification, color(), - name(), + title, std::move(embeds), "", screenshot_view() );