Skip to content

Commit c82db11

Browse files
authored
UnexpectedBattleException now inherits OperationFailedException (#658)
* UnexpectedBattleException now inherits OperationFailedException * fix build
1 parent dc23d98 commit c82db11

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@
77
#ifndef PokemonAutomation_UnexpectedBattleException_H
88
#define PokemonAutomation_UnexpectedBattleException_H
99

10-
#include "ScreenshotException.h"
10+
#include "OperationFailedException.h"
1111

1212
namespace PokemonAutomation{
13-
14-
class FatalProgramException;
15-
13+
namespace NintendoSwitch{
1614

1715
// Thrown by subroutines if caught in an wild battle in-game unexpectedly.
1816
// These include recoverable errors which can be consumed by the program.
19-
class UnexpectedBattleException : public ScreenshotException{
17+
class UnexpectedBattleException : public OperationFailedException{
2018
public:
21-
using ScreenshotException::ScreenshotException;
19+
UnexpectedBattleException(
20+
ErrorReport error_report,
21+
std::string message,
22+
VideoStream& stream
23+
)
24+
: OperationFailedException(error_report, std::move(message), stream)
25+
{}
2226

2327
virtual const char* name() const override{ return "UnexpectedBattleException"; }
2428
};
@@ -27,5 +31,6 @@ class UnexpectedBattleException : public ScreenshotException{
2731

2832

2933

34+
}
3035
}
3136
#endif

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,11 +1071,11 @@ void realign_player_from_landmark(
10711071

10721072
return;
10731073

1074+
}catch (UnexpectedBattleException&){
1075+
run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD);
10741076
}catch (OperationFailedException&){
10751077
// reset to overworld if failed to center on the pokecenter, and re-try
10761078
leave_phone_to_overworld(info, stream, context);
1077-
}catch (UnexpectedBattleException&){
1078-
run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD);
10791079
}
10801080
}
10811081

@@ -1153,11 +1153,11 @@ void move_cursor_towards_flypoint_and_go_there(
11531153

11541154
return;
11551155

1156+
}catch (UnexpectedBattleException&){
1157+
run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD);
11561158
}catch (OperationFailedException&){
11571159
// reset to overworld if failed to center on the pokecenter, and re-try
11581160
leave_phone_to_overworld(info, stream, context);
1159-
}catch (UnexpectedBattleException&){
1160-
run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD);
11611161
}
11621162
}
11631163

0 commit comments

Comments
 (0)