Skip to content

Commit 4da5a2d

Browse files
authored
olive action failed exception (#499)
1 parent 605bc05 commit 4da5a2d

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ file(GLOB MAIN_SOURCES
307307
Source/CommonFramework/Environment/SystemSleep.h
308308
Source/CommonFramework/Exceptions/FatalProgramException.cpp
309309
Source/CommonFramework/Exceptions/FatalProgramException.h
310+
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp
311+
Source/CommonFramework/Exceptions/OliveActionFailedException.h
310312
Source/CommonFramework/Exceptions/OperationFailedException.cpp
311313
Source/CommonFramework/Exceptions/OperationFailedException.h
312314
Source/CommonFramework/Exceptions/ProgramFinishedException.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ SOURCES += \
179179
Source/CommonFramework/Environment/HardwareValidation.cpp \
180180
Source/CommonFramework/Environment/SystemSleep.cpp \
181181
Source/CommonFramework/Exceptions/FatalProgramException.cpp \
182+
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp \
182183
Source/CommonFramework/Exceptions/OperationFailedException.cpp \
183184
Source/CommonFramework/Exceptions/ProgramFinishedException.cpp \
184185
Source/CommonFramework/Exceptions/ScreenshotException.cpp \
@@ -1235,6 +1236,7 @@ HEADERS += \
12351236
Source/CommonFramework/Environment/HardwareValidation_x86.tpp \
12361237
Source/CommonFramework/Environment/SystemSleep.h \
12371238
Source/CommonFramework/Exceptions/FatalProgramException.h \
1239+
Source/CommonFramework/Exceptions/OliveActionFailedException.h \
12381240
Source/CommonFramework/Exceptions/OperationFailedException.h \
12391241
Source/CommonFramework/Exceptions/ProgramFinishedException.h \
12401242
Source/CommonFramework/Exceptions/ScreenshotException.h \
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* Operation Failed Exception
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "CommonFramework/ImageTypes/ImageRGB32.h"
8+
#include "CommonFramework/Notifications/ProgramNotifications.h"
9+
#include "CommonFramework/Tools/ErrorDumper.h"
10+
#include "CommonFramework/Tools/ProgramEnvironment.h"
11+
#include "CommonFramework/Tools/ConsoleHandle.h"
12+
#include "OliveActionFailedException.h"
13+
14+
namespace PokemonAutomation{
15+
16+
17+
OliveActionFailedException::OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, OliveFail fail_reason)
18+
: OperationFailedException(error_report, logger, std::move(message))
19+
, m_fail_reason(fail_reason)
20+
{}
21+
OliveActionFailedException::OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, std::shared_ptr<const ImageRGB32> screenshot, OliveFail fail_reason)
22+
: OperationFailedException(error_report, logger, std::move(message), std::move(screenshot))
23+
, m_fail_reason(fail_reason)
24+
{}
25+
OliveActionFailedException::OliveActionFailedException(ErrorReport error_report, ConsoleHandle& console, std::string message, bool take_screenshot, OliveFail fail_reason)
26+
: OperationFailedException(error_report, console, std::move(message), take_screenshot)
27+
, m_fail_reason(fail_reason)
28+
{}
29+
30+
31+
32+
33+
34+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Operation Failed Exception
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_OliveActionFailedException_H
8+
#define PokemonAutomation_OliveActionFailedException_H
9+
10+
#include <memory>
11+
#include "OperationFailedException.h"
12+
13+
namespace PokemonAutomation{
14+
15+
class FatalProgramException;
16+
17+
enum class OliveFail{
18+
NONE,
19+
FAILED_ALIGN_TO_OLIVE,
20+
FAILED_PUSH_OLIVE_TOTAL_DISTANCE,
21+
NO_OLIVE_DETECTED,
22+
FAILED_WALK_TO_OLIVE,
23+
OLIVE_STUCK,
24+
};
25+
26+
// Thrown by subroutines if they fail for an in-game reason.
27+
// These include recoverable errors which can be consumed by the program.
28+
class OliveActionFailedException : public OperationFailedException{
29+
public:
30+
explicit OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, OliveFail fail_reason = OliveFail::NONE);
31+
explicit OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, std::shared_ptr<const ImageRGB32> screenshot, OliveFail fail_reason = OliveFail::NONE);
32+
explicit OliveActionFailedException(ErrorReport error_report, ConsoleHandle& console, std::string message, bool take_screenshot, OliveFail fail_reason = OliveFail::NONE);
33+
34+
virtual const char* name() const override{ return "OliveActionFailedException"; }
35+
36+
public:
37+
OliveFail m_fail_reason;
38+
39+
};
40+
41+
42+
43+
44+
45+
}
46+
#endif

0 commit comments

Comments
 (0)