Skip to content

Commit 62a59e6

Browse files
committed
Refactor error reporting.
1 parent 3197037 commit 62a59e6

32 files changed

+863
-280
lines changed

Common/Cpp/AbstractLogger.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#define PokemonAutomation_AbstractLogger_H
99

1010
#include <string>
11+
#include <vector>
1112
#include "Color.h"
13+
#include "Time.h"
1214

1315
namespace PokemonAutomation{
1416

@@ -22,6 +24,10 @@ class Logger{
2224
virtual void log(const char* msg, Color color = Color()){
2325
log(std::string(msg), color);
2426
}
27+
28+
virtual std::vector<std::string> get_last() const{
29+
return {};
30+
}
2531
};
2632

2733

Common/Cpp/Json/JsonValue.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "JsonObject.h"
1111
#include "JsonTools.h"
1212

13+
//#include <iostream>
14+
//using std::cout;
15+
//using std::endl;
16+
1317
namespace PokemonAutomation{
1418

1519

@@ -365,8 +369,9 @@ bool JsonValue::read_string(std::string& value) const{
365369
JsonValue parse_json(const std::string& str){
366370
return from_nlohmann(nlohmann::json::parse(str, nullptr, false));
367371
}
368-
JsonValue load_json_file(const std::string& str){
369-
return parse_json(file_to_string(str));
372+
JsonValue load_json_file(const std::string& filename){
373+
std::string str = file_to_string(filename);
374+
return parse_json(str);
370375
}
371376
std::string JsonValue::dump(int indent) const{
372377
return to_nlohmann(*this).dump(indent);

Common/Cpp/Json/JsonValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class JsonValue{
161161
};
162162

163163
JsonValue parse_json(const std::string& str);
164-
JsonValue load_json_file(const std::string& str);
164+
JsonValue load_json_file(const std::string& filename);
165165

166166

167167
template <typename Type>

SerialPrograms/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,6 @@ file(GLOB MAIN_SOURCES
287287
Source/CommonFramework/ControllerDevices/SerialPortSession.h
288288
Source/CommonFramework/ControllerDevices/SerialPortWidget.cpp
289289
Source/CommonFramework/ControllerDevices/SerialPortWidget.h
290-
Source/CommonFramework/CrashDump.cpp
291-
Source/CommonFramework/CrashDump.h
292290
Source/CommonFramework/Environment/Environment.cpp
293291
Source/CommonFramework/Environment/Environment.h
294292
Source/CommonFramework/Environment/Environment_Linux.h
@@ -307,6 +305,11 @@ file(GLOB MAIN_SOURCES
307305
Source/CommonFramework/Environment/SystemSleep.h
308306
Source/CommonFramework/Environment/SystemSleep_Apple.tpp
309307
Source/CommonFramework/Environment/SystemSleep_Windows.tpp
308+
Source/CommonFramework/ErrorReports/ErrorReports.cpp
309+
Source/CommonFramework/ErrorReports/ErrorReports.h
310+
Source/CommonFramework/ErrorReports/ProgramDumper.cpp
311+
Source/CommonFramework/ErrorReports/ProgramDumper.h
312+
Source/CommonFramework/ErrorReports/ProgramDumper_Windows.tpp
310313
Source/CommonFramework/Exceptions/FatalProgramException.cpp
311314
Source/CommonFramework/Exceptions/FatalProgramException.h
312315
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp
@@ -2080,11 +2083,12 @@ target_link_libraries(SerialPrograms PRIVATE Threads::Threads)
20802083
#add defines
20812084
target_compile_definitions(SerialPrograms PRIVATE NOMINMAX)
20822085

2083-
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/TelemetryURLs.h")
2086+
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/Internal0.cpp")
20842087
target_compile_definitions(SerialPrograms PRIVATE PA_OFFICIAL)
2085-
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/TelemetryURLs.h)
20862088
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.cpp)
20872089
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.h)
2090+
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/Internal0.cpp)
2091+
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/Internal1.cpp)
20882092
endif()
20892093

20902094
#extract opencv_world460d.dll from archive on Windows Debug builds

SerialPrograms/SerialPrograms.pro

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ SOURCES += \
174174
Source/CommonFramework/ControllerDevices/SerialPortOption.cpp \
175175
Source/CommonFramework/ControllerDevices/SerialPortSession.cpp \
176176
Source/CommonFramework/ControllerDevices/SerialPortWidget.cpp \
177-
Source/CommonFramework/CrashDump.cpp \
178177
Source/CommonFramework/Environment/Environment.cpp \
179178
Source/CommonFramework/Environment/HardwareValidation.cpp \
180179
Source/CommonFramework/Environment/SystemSleep.cpp \
180+
Source/CommonFramework/ErrorReports/ErrorReports.cpp \
181+
Source/CommonFramework/ErrorReports/ProgramDumper.cpp \
181182
Source/CommonFramework/Exceptions/FatalProgramException.cpp \
182183
Source/CommonFramework/Exceptions/OliveActionFailedException.cpp \
183184
Source/CommonFramework/Exceptions/OperationFailedException.cpp \
@@ -1234,7 +1235,6 @@ HEADERS += \
12341235
Source/CommonFramework/ControllerDevices/SerialPortOption.h \
12351236
Source/CommonFramework/ControllerDevices/SerialPortSession.h \
12361237
Source/CommonFramework/ControllerDevices/SerialPortWidget.h \
1237-
Source/CommonFramework/CrashDump.h \
12381238
Source/CommonFramework/Environment/Environment.h \
12391239
Source/CommonFramework/Environment/Environment_Linux.h \
12401240
Source/CommonFramework/Environment/Environment_Linux.tpp \
@@ -1250,6 +1250,9 @@ HEADERS += \
12501250
Source/CommonFramework/Environment/SystemSleep.h \
12511251
Source/CommonFramework/Environment/SystemSleep_Apple.tpp \
12521252
Source/CommonFramework/Environment/SystemSleep_Windows.tpp \
1253+
Source/CommonFramework/ErrorReports/ErrorReports.h \
1254+
Source/CommonFramework/ErrorReports/ProgramDumper.h \
1255+
Source/CommonFramework/ErrorReports/ProgramDumper_Windows.tpp \
12531256
Source/CommonFramework/Exceptions/FatalProgramException.h \
12541257
Source/CommonFramework/Exceptions/OliveActionFailedException.h \
12551258
Source/CommonFramework/Exceptions/OperationFailedException.h \
@@ -2137,10 +2140,12 @@ HEADERS += \
21372140

21382141

21392142

2140-
exists(../../Internal/SerialPrograms/TelemetryURLs.h){
2143+
exists(../../Internal/SerialPrograms/Internal0.cpp){
21412144
DEFINES += PA_OFFICIAL
21422145
SOURCES += ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.cpp
21432146
HEADERS += ../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.h
2147+
SOURCES += ../../Internal/SerialPrograms/Internal0.cpp
2148+
SOURCES += ../../Internal/SerialPrograms/Internal1.cpp
21442149
}
21452150

21462151

SerialPrograms/Source/CommonFramework/CrashDump.cpp

Lines changed: 0 additions & 114 deletions
This file was deleted.

SerialPrograms/Source/CommonFramework/CrashDump.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)