diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp index eb85bfe12b..35bf7bd6b9 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 @@ -105,12 +108,33 @@ void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotifi send_program_notification( env, notification, color(), - name(), + title, std::move(embeds), "", screenshot_view() ); } +void ScreenshotException::send_recoverable_notification(ProgramEnvironment& env) const{ + EventNotificationOption recoverable_notification = EventNotificationOption( + "Program Error (Recoverable)", + true, true, + ImageAttachmentMode::JPG, + {"Notifs"} + ); + + send_notification(env, recoverable_notification, "Recoverable: "); +} + +void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const{ + EventNotificationOption fatal_notification = EventNotificationOption( + "Program Error (Fatal)", + true, true, + ImageAttachmentMode::JPG, + {"Notifs"} + ); + + send_notification(env, fatal_notification, "Fatal: "); +} diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h index e10a8c313f..8a8b049cdd 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h +++ b/SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h @@ -71,7 +71,9 @@ 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: 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..c980adfb82 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_recoverable_notification(env); env.log("Reset game to handle recoverable error"); reset_game(env.program_info(), env.console, context);