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 @@ -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"; }
};
Expand All @@ -27,5 +31,6 @@ class UnexpectedBattleException : public ScreenshotException{



}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down