Skip to content

Commit 670b958

Browse files
committed
refactor: print error with LeviLamina's interface
1 parent 14bbe10 commit 670b958

File tree

9 files changed

+17
-15
lines changed

9 files changed

+17
-15
lines changed

src/legacy/api/DataAPI.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ Local<Value> DataClass::toJson(const Arguments& args) {
851851
try {
852852
return String::newString(ValueToJson(args[0], spaces));
853853
} catch (...) {
854+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
854855
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, "Failed to transform into Json.");
855856
return Local<Value>();
856857
}
@@ -866,6 +867,7 @@ Local<Value> DataClass::parseJson(const Arguments& args) {
866867
try {
867868
return JsonToValue(args[0].asString().toString());
868869
} catch (...) {
870+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
869871
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, "Failed to parse from Json.");
870872
return Local<Value>();
871873
}

src/legacy/api/EventAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ void InitBasicEventListeners() {
938938
}
939939
} catch (...) {
940940
lse::getSelfPluginInstance().getLogger().error("Error occurred in Engine Message Loop!");
941-
lse::getSelfPluginInstance().getLogger().error("Uncaught Exception Detected!");
941+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
942942
}
943943
#endif
944944

src/legacy/api/NetworkAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ Local<Value> WSClientClass::connectAsync(const Arguments& args) {
367367
NewTimeout(callback.get(), {Boolean::newBoolean(result)}, 0);
368368
} catch (...) {
369369
lse::getSelfPluginInstance().getLogger().error("WSClientClass::connectAsync Failed!");
370-
lse::getSelfPluginInstance().getLogger().error("Uncaught Exception Detected!");
370+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
371371
lse::getSelfPluginInstance().getLogger().error("In Plugin: " + pluginName);
372372
}
373373
}).detach();

src/legacy/api/SystemAPI.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,6 @@ bool NewProcess(
8787
if (callback) callback(static_cast<int>(exitCode), std::move(strOutput));
8888
} catch (...) {
8989
lse::getSelfPluginInstance().getLogger().error("NewProcess Callback Failed!");
90-
91-
ll::utils::error_utils::AnyExceptionRef anyExc(std::current_exception());
92-
if (auto exc = anyExc.tryGet<std::exception>()) {
93-
lse::getSelfPluginInstance().getLogger().error("Caught Exception: {}", exc->what());
94-
} else {
95-
lse::getSelfPluginInstance().getLogger().error("Unknown exception caught in NewProcess callback.");
96-
}
97-
9890
ll::utils::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
9991
}
10092
}).detach();

src/legacy/engine/MessageSystem.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ ModuleMessageResult ModuleMessage::broadcastLocal(MessageType type, string data,
116116
"Fail to post message to plugin {}",
117117
getEngineData(engine)->pluginName
118118
);
119+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
119120
}
120121
}
121122
return ModuleMessageResult(msgId, engineList);
@@ -146,6 +147,7 @@ ModuleMessageResult ModuleMessage::broadcastGlobal(MessageType type, string data
146147
"Fail to post message to plugin {}",
147148
getEngineData(engine)->pluginName
148149
);
150+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
149151
}
150152
}
151153
return ModuleMessageResult(msgId, engineList);
@@ -177,6 +179,7 @@ ModuleMessageResult ModuleMessage::broadcastTo(std::string toModuleType, Message
177179
"Fail to post message to plugin {}",
178180
getEngineData(engine)->pluginName
179181
);
182+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
180183
}
181184
}
182185
}
@@ -206,6 +209,7 @@ ModuleMessageResult ModuleMessage::sendTo(ScriptEngine* engine, MessageType type
206209
"Fail to post message to plugin {}",
207210
getEngineData(engine)->pluginName
208211
);
212+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
209213
}
210214
return ModuleMessageResult(msgId, {});
211215
}
@@ -236,6 +240,7 @@ ModuleMessage::sendToRandom(std::string toModuleType, MessageType type, std::str
236240
"Fail to post message to plugin {}",
237241
getEngineData(engine)->pluginName
238242
);
243+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
239244
}
240245
}
241246
}
@@ -264,6 +269,7 @@ bool ModuleMessage::sendResult(MessageType typ, std::string dat, int64_t delay)
264269
"Fail to post message to plugin {}",
265270
getEngineData(engine)->pluginName
266271
);
272+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
267273
}
268274
return false;
269275
}
@@ -333,12 +339,11 @@ void MessageSystemLoopOnce() {
333339
} catch (const Exception& e) {
334340
EngineScope scope(engine);
335341
lse::getSelfPluginInstance().getLogger().error("Error occurred in Engine Message Loop!");
336-
lse::getSelfPluginInstance().getLogger().error("Uncaught Script Exception Detected!");
337342
ll::error_utils::printException(e, lse::getSelfPluginInstance().getLogger());
338343
lse::getSelfPluginInstance().getLogger().error("In Plugin: " + getEngineOwnData()->pluginName);
339344
} catch (...) {
340345
lse::getSelfPluginInstance().getLogger().error("Error occurred in Engine Message Loop!");
341-
lse::getSelfPluginInstance().getLogger().error("Uncaught Exception Detected!");
346+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
342347
}
343348
}
344349
}

src/legacy/engine/RemoteCall.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,14 @@ void RemoteSyncCallRequest(ModuleMessage& msg) {
7272
// Feedback
7373
if (!msg.sendResult(ModuleMessage::MessageType::RemoteSyncCallReturn, "[null]")) {
7474
lse::getSelfPluginInstance().getLogger().error("Fail to post remote call result return!");
75-
;
7675
}
7776
} catch (...) {
7877
lse::getSelfPluginInstance().getLogger().error("Error occurred in remote engine!");
78+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
7979

8080
// Feedback
8181
if (!msg.sendResult(ModuleMessage::MessageType::RemoteSyncCallReturn, "[null]")) {
8282
lse::getSelfPluginInstance().getLogger().error("Fail to post remote call result return!");
83-
;
8483
}
8584
}
8685
}

src/legacy/engine/TimeTaskSystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ bool ClearTimeTask(int const& id) {
192192
}
193193
} catch (...) {
194194
lse::getSelfPluginInstance().getLogger().error("Fail in ClearTimeTask");
195+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
195196
}
196197
return true;
197198
}
@@ -209,5 +210,6 @@ void LLSERemoveTimeTaskData(ScriptEngine* engine) {
209210
}
210211
} catch (...) {
211212
lse::getSelfPluginInstance().getLogger().info("Fail in LLSERemoveTimeTaskData");
213+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
212214
}
213215
}

src/legacy/main/NodeJsHelper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ bool stopEngine(node::Environment* env) {
218218
return true;
219219
} catch (...) {
220220
lse::getSelfPluginInstance().getLogger().error("Fail to stop engine {}", (void*)env);
221+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
221222
return false;
222223
}
223224
}
@@ -355,6 +356,7 @@ int executeNpmCommand(std::string cmd, std::string workingDir) {
355356
exit_code = node::SpinEventLoop(env).FromMaybe(1);
356357
} catch (...) {
357358
lse::getSelfPluginInstance().getLogger().error("Fail to execute NPM command. Error occurs");
359+
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger());
358360
}
359361
}
360362

src/legacy/main/PythonHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ bool processPythonDebugEngine(const std::string& cmd) {
208208
} catch (const Exception& e) {
209209
isInsideCodeBlock = false;
210210
codeBuffer.clear();
211-
lse::getSelfPluginInstance().getLogger().error("Exception:\n" + e.stacktrace() + "\n" + e.message());
211+
ll::error_utils::printException(e, lse::getSelfPluginInstance().getLogger());
212212
}
213213
}
214214
OUTPUT_DEBUG_SIGN();

0 commit comments

Comments
 (0)