diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h b/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h index 30e609c5c1..78441276c9 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h +++ b/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h @@ -7,18 +7,22 @@ #ifndef PokemonAutomation_UnexpectedBattleException_H #define PokemonAutomation_UnexpectedBattleException_H -#include "ScreenshotException.h" +#include "OperationFailedException.h" namespace PokemonAutomation{ - -class FatalProgramException; - +namespace NintendoSwitch{ // Thrown by subroutines if caught in an wild battle in-game unexpectedly. // These include recoverable errors which can be consumed by the program. -class UnexpectedBattleException : public ScreenshotException{ +class UnexpectedBattleException : public OperationFailedException{ public: - using ScreenshotException::ScreenshotException; + UnexpectedBattleException( + ErrorReport error_report, + std::string message, + VideoStream& stream + ) + : OperationFailedException(error_report, std::move(message), stream) + {} virtual const char* name() const override{ return "UnexpectedBattleException"; } }; @@ -27,5 +31,6 @@ class UnexpectedBattleException : public ScreenshotException{ +} } #endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 1b74969e3d..8eca9d666e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1071,11 +1071,11 @@ void realign_player_from_landmark( return; + }catch (UnexpectedBattleException&){ + run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD); }catch (OperationFailedException&){ // reset to overworld if failed to center on the pokecenter, and re-try leave_phone_to_overworld(info, stream, context); - }catch (UnexpectedBattleException&){ - run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD); } } @@ -1153,11 +1153,11 @@ void move_cursor_towards_flypoint_and_go_there( return; + }catch (UnexpectedBattleException&){ + run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD); }catch (OperationFailedException&){ // reset to overworld if failed to center on the pokecenter, and re-try leave_phone_to_overworld(info, stream, context); - }catch (UnexpectedBattleException&){ - run_battle_press_A(stream, context, BattleStopCondition::STOP_OVERWORLD); } }