Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ std::shared_ptr<const ImageRGB32> 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<std::pair<std::string, std::string>> embeds;
if (!m_message.empty()){
embeds.emplace_back(std::pair<std::string, std::string>("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
Expand All @@ -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: ");
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class ScreenshotException : public Exception{
std::shared_ptr<const ImageRGB32> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,6 @@ bool EggAutonomous::handle_recoverable_error(
auto& stats = env.current_stats<EggAutonomous_Descriptor::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
Expand Down Expand Up @@ -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);
Expand Down