Skip to content

Commit

Permalink
Refactor error reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticial committed Nov 29, 2024
1 parent 3197037 commit 62a59e6
Show file tree
Hide file tree
Showing 32 changed files with 863 additions and 280 deletions.
6 changes: 6 additions & 0 deletions Common/Cpp/AbstractLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#define PokemonAutomation_AbstractLogger_H

#include <string>
#include <vector>
#include "Color.h"
#include "Time.h"

namespace PokemonAutomation{

Expand All @@ -22,6 +24,10 @@ class Logger{
virtual void log(const char* msg, Color color = Color()){
log(std::string(msg), color);
}

virtual std::vector<std::string> get_last() const{
return {};
}
};


Expand Down
9 changes: 7 additions & 2 deletions Common/Cpp/Json/JsonValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "JsonObject.h"
#include "JsonTools.h"

//#include <iostream>
//using std::cout;
//using std::endl;

namespace PokemonAutomation{


Expand Down Expand Up @@ -365,8 +369,9 @@ bool JsonValue::read_string(std::string& value) const{
JsonValue parse_json(const std::string& str){
return from_nlohmann(nlohmann::json::parse(str, nullptr, false));
}
JsonValue load_json_file(const std::string& str){
return parse_json(file_to_string(str));
JsonValue load_json_file(const std::string& filename){
std::string str = file_to_string(filename);
return parse_json(str);
}
std::string JsonValue::dump(int indent) const{
return to_nlohmann(*this).dump(indent);
Expand Down
2 changes: 1 addition & 1 deletion Common/Cpp/Json/JsonValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class JsonValue{
};

JsonValue parse_json(const std::string& str);
JsonValue load_json_file(const std::string& str);
JsonValue load_json_file(const std::string& filename);


template <typename Type>
Expand Down
12 changes: 8 additions & 4 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ file(GLOB MAIN_SOURCES
Source/CommonFramework/ControllerDevices/SerialPortSession.h
Source/CommonFramework/ControllerDevices/SerialPortWidget.cpp
Source/CommonFramework/ControllerDevices/SerialPortWidget.h
Source/CommonFramework/CrashDump.cpp
Source/CommonFramework/CrashDump.h
Source/CommonFramework/Environment/Environment.cpp
Source/CommonFramework/Environment/Environment.h
Source/CommonFramework/Environment/Environment_Linux.h
Expand All @@ -307,6 +305,11 @@ file(GLOB MAIN_SOURCES
Source/CommonFramework/Environment/SystemSleep.h
Source/CommonFramework/Environment/SystemSleep_Apple.tpp
Source/CommonFramework/Environment/SystemSleep_Windows.tpp
Source/CommonFramework/ErrorReports/ErrorReports.cpp
Source/CommonFramework/ErrorReports/ErrorReports.h
Source/CommonFramework/ErrorReports/ProgramDumper.cpp
Source/CommonFramework/ErrorReports/ProgramDumper.h
Source/CommonFramework/ErrorReports/ProgramDumper_Windows.tpp
Source/CommonFramework/Exceptions/FatalProgramException.cpp
Source/CommonFramework/Exceptions/FatalProgramException.h
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp
Expand Down Expand Up @@ -2080,11 +2083,12 @@ target_link_libraries(SerialPrograms PRIVATE Threads::Threads)
#add defines
target_compile_definitions(SerialPrograms PRIVATE NOMINMAX)

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/TelemetryURLs.h")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/Internal0.cpp")
target_compile_definitions(SerialPrograms PRIVATE PA_OFFICIAL)
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/TelemetryURLs.h)
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.cpp)
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.h)
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/Internal0.cpp)
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/Internal1.cpp)
endif()

#extract opencv_world460d.dll from archive on Windows Debug builds
Expand Down
11 changes: 8 additions & 3 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ SOURCES += \
Source/CommonFramework/ControllerDevices/SerialPortOption.cpp \
Source/CommonFramework/ControllerDevices/SerialPortSession.cpp \
Source/CommonFramework/ControllerDevices/SerialPortWidget.cpp \
Source/CommonFramework/CrashDump.cpp \
Source/CommonFramework/Environment/Environment.cpp \
Source/CommonFramework/Environment/HardwareValidation.cpp \
Source/CommonFramework/Environment/SystemSleep.cpp \
Source/CommonFramework/ErrorReports/ErrorReports.cpp \
Source/CommonFramework/ErrorReports/ProgramDumper.cpp \
Source/CommonFramework/Exceptions/FatalProgramException.cpp \
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp \
Source/CommonFramework/Exceptions/OperationFailedException.cpp \
Expand Down Expand Up @@ -1234,7 +1235,6 @@ HEADERS += \
Source/CommonFramework/ControllerDevices/SerialPortOption.h \
Source/CommonFramework/ControllerDevices/SerialPortSession.h \
Source/CommonFramework/ControllerDevices/SerialPortWidget.h \
Source/CommonFramework/CrashDump.h \
Source/CommonFramework/Environment/Environment.h \
Source/CommonFramework/Environment/Environment_Linux.h \
Source/CommonFramework/Environment/Environment_Linux.tpp \
Expand All @@ -1250,6 +1250,9 @@ HEADERS += \
Source/CommonFramework/Environment/SystemSleep.h \
Source/CommonFramework/Environment/SystemSleep_Apple.tpp \
Source/CommonFramework/Environment/SystemSleep_Windows.tpp \
Source/CommonFramework/ErrorReports/ErrorReports.h \
Source/CommonFramework/ErrorReports/ProgramDumper.h \
Source/CommonFramework/ErrorReports/ProgramDumper_Windows.tpp \
Source/CommonFramework/Exceptions/FatalProgramException.h \
Source/CommonFramework/Exceptions/OliveActionFailedException.h \
Source/CommonFramework/Exceptions/OperationFailedException.h \
Expand Down Expand Up @@ -2137,10 +2140,12 @@ HEADERS += \



exists(../../Internal/SerialPrograms/TelemetryURLs.h){
exists(../../Internal/SerialPrograms/Internal0.cpp){
DEFINES += PA_OFFICIAL
SOURCES += ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.cpp
HEADERS += ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.h
SOURCES += ../../Internal/SerialPrograms/Internal0.cpp
SOURCES += ../../Internal/SerialPrograms/Internal1.cpp
}


Expand Down
114 changes: 0 additions & 114 deletions SerialPrograms/Source/CommonFramework/CrashDump.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions SerialPrograms/Source/CommonFramework/CrashDump.h

This file was deleted.

Loading

0 comments on commit 62a59e6

Please sign in to comment.