Skip to content

Commit

Permalink
olive action failed exception (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
jw098 authored Nov 3, 2024
1 parent 605bc05 commit 4da5a2d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ file(GLOB MAIN_SOURCES
Source/CommonFramework/Environment/SystemSleep.h
Source/CommonFramework/Exceptions/FatalProgramException.cpp
Source/CommonFramework/Exceptions/FatalProgramException.h
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp
Source/CommonFramework/Exceptions/OliveActionFailedException.h
Source/CommonFramework/Exceptions/OperationFailedException.cpp
Source/CommonFramework/Exceptions/OperationFailedException.h
Source/CommonFramework/Exceptions/ProgramFinishedException.cpp
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ SOURCES += \
Source/CommonFramework/Environment/HardwareValidation.cpp \
Source/CommonFramework/Environment/SystemSleep.cpp \
Source/CommonFramework/Exceptions/FatalProgramException.cpp \
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp \
Source/CommonFramework/Exceptions/OperationFailedException.cpp \
Source/CommonFramework/Exceptions/ProgramFinishedException.cpp \
Source/CommonFramework/Exceptions/ScreenshotException.cpp \
Expand Down Expand Up @@ -1235,6 +1236,7 @@ HEADERS += \
Source/CommonFramework/Environment/HardwareValidation_x86.tpp \
Source/CommonFramework/Environment/SystemSleep.h \
Source/CommonFramework/Exceptions/FatalProgramException.h \
Source/CommonFramework/Exceptions/OliveActionFailedException.h \
Source/CommonFramework/Exceptions/OperationFailedException.h \
Source/CommonFramework/Exceptions/ProgramFinishedException.h \
Source/CommonFramework/Exceptions/ScreenshotException.h \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Operation Failed Exception
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#include "CommonFramework/ImageTypes/ImageRGB32.h"
#include "CommonFramework/Notifications/ProgramNotifications.h"
#include "CommonFramework/Tools/ErrorDumper.h"
#include "CommonFramework/Tools/ProgramEnvironment.h"
#include "CommonFramework/Tools/ConsoleHandle.h"
#include "OliveActionFailedException.h"

namespace PokemonAutomation{


OliveActionFailedException::OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, OliveFail fail_reason)
: OperationFailedException(error_report, logger, std::move(message))
, m_fail_reason(fail_reason)
{}
OliveActionFailedException::OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, std::shared_ptr<const ImageRGB32> screenshot, OliveFail fail_reason)
: OperationFailedException(error_report, logger, std::move(message), std::move(screenshot))
, m_fail_reason(fail_reason)
{}
OliveActionFailedException::OliveActionFailedException(ErrorReport error_report, ConsoleHandle& console, std::string message, bool take_screenshot, OliveFail fail_reason)
: OperationFailedException(error_report, console, std::move(message), take_screenshot)
, m_fail_reason(fail_reason)
{}





}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* Operation Failed Exception
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#ifndef PokemonAutomation_OliveActionFailedException_H
#define PokemonAutomation_OliveActionFailedException_H

#include <memory>
#include "OperationFailedException.h"

namespace PokemonAutomation{

class FatalProgramException;

enum class OliveFail{
NONE,
FAILED_ALIGN_TO_OLIVE,
FAILED_PUSH_OLIVE_TOTAL_DISTANCE,
NO_OLIVE_DETECTED,
FAILED_WALK_TO_OLIVE,
OLIVE_STUCK,
};

// Thrown by subroutines if they fail for an in-game reason.
// These include recoverable errors which can be consumed by the program.
class OliveActionFailedException : public OperationFailedException{
public:
explicit OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, OliveFail fail_reason = OliveFail::NONE);
explicit OliveActionFailedException(ErrorReport error_report, Logger& logger, std::string message, std::shared_ptr<const ImageRGB32> screenshot, OliveFail fail_reason = OliveFail::NONE);
explicit OliveActionFailedException(ErrorReport error_report, ConsoleHandle& console, std::string message, bool take_screenshot, OliveFail fail_reason = OliveFail::NONE);

virtual const char* name() const override{ return "OliveActionFailedException"; }

public:
OliveFail m_fail_reason;

};





}
#endif

0 comments on commit 4da5a2d

Please sign in to comment.