From 0caac8ae47d2f46152b9b9beebec101255462255 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 2 Aug 2025 11:20:12 -0700 Subject: [PATCH 1/2] UnexpectedBattleException now inherits OperationFailedException --- .../CommonFramework/Exceptions/UnexpectedBattleException.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h b/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h index 30e609c5c1..ffb964d4a1 100644 --- a/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h +++ b/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h @@ -16,7 +16,7 @@ class FatalProgramException; // 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; From 731d2507db10cc368513a6cb6862bff96065b5be Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 2 Aug 2025 11:45:47 -0700 Subject: [PATCH 2/2] fix build --- .../Exceptions/UnexpectedBattleException.h | 15 ++++++++++----- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h b/SerialPrograms/Source/CommonFramework/Exceptions/UnexpectedBattleException.h index ffb964d4a1..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 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 OperationFailedException{ +} } #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); } }