Skip to content

Commit cd31edc

Browse files
committed
add send_recoverable_notification()
1 parent a07d936 commit cd31edc

File tree

3 files changed

+19
-29
lines changed

3 files changed

+19
-29
lines changed

SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.cpp

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,20 @@ std::shared_ptr<const ImageRGB32> ScreenshotException::screenshot() const{
8585
}
8686

8787

88-
void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotificationOption& notification) const{
88+
void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotificationOption& notification, const std::string& title_prefix) const{
8989
std::vector<std::pair<std::string, std::string>> embeds;
9090
if (!m_message.empty()){
9191
embeds.emplace_back(std::pair<std::string, std::string>("Message:", m_message));
9292
}
9393

94+
std::string title = title_prefix;
95+
title.append(name());
96+
9497
if (m_send_error_report == ErrorReport::SEND_ERROR_REPORT){
9598
report_error(
9699
&env.logger(),
97100
env.program_info(),
98-
name(),
101+
title,
99102
embeds,
100103
screenshot_view(),
101104
m_stream ? &m_stream->history() : nullptr
@@ -111,40 +114,26 @@ void ScreenshotException::send_notification(ProgramEnvironment& env, EventNotifi
111114
);
112115
}
113116

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());
117+
void ScreenshotException::send_recoverable_notification(ProgramEnvironment& env) const{
118+
EventNotificationOption recoverable_notification = EventNotificationOption(
119+
"Program Error (Recoverable)",
120+
true, true,
121+
ImageAttachmentMode::JPG,
122+
{"Notifs"}
123+
);
122124

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-
}
125+
send_notification(env, recoverable_notification, "Recoverable Error: ");
126+
}
133127

128+
void ScreenshotException::send_fatal_notification(ProgramEnvironment& env) const{
134129
EventNotificationOption fatal_notification = EventNotificationOption(
135130
"Program Error (Fatal)",
136131
true, true,
137132
ImageAttachmentMode::JPG,
138133
{"Notifs"}
139134
);
140135

141-
send_program_notification(
142-
env, fatal_notification,
143-
color(),
144-
name(),
145-
std::move(embeds), "",
146-
screenshot_view()
147-
);
136+
send_notification(env, fatal_notification, "Recoverable Error: ");
148137
}
149138

150139

SerialPrograms/Source/CommonFramework/Exceptions/ScreenshotException.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class ScreenshotException : public Exception{
7171
std::shared_ptr<const ImageRGB32> screenshot() const;
7272

7373
virtual Color color() const{ return COLOR_RED; }
74-
virtual void send_notification(ProgramEnvironment& env, EventNotificationOption& notification) const;
74+
virtual void send_notification(ProgramEnvironment& env, EventNotificationOption& notification, const std::string& title_prefix = "") const;
75+
void send_recoverable_notification(ProgramEnvironment& env) const;
7576
void send_fatal_notification(ProgramEnvironment& env) const;
7677

7778
public:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ bool EggAutonomous::handle_recoverable_error(
796796
env.console
797797
);
798798
}
799-
e.send_notification(env, notification);
799+
e.send_recoverable_notification(env);
800800

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

0 commit comments

Comments
 (0)