Skip to content

Commit

Permalink
[unity]on_fail回调里错误信息信息添加错误码
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Dec 10, 2024
1 parent 3b9a71d commit ee32720
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions unreal/Puerts/Source/JsEnv/Private/WebSocketImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,10 @@ void V8WebSocketClientImpl::OnFail(wspp_connection_hdl InHandle)
if (!Handles[ON_FAIL].IsEmpty())
{
wspp_client::connection_ptr con = Client.get_con_from_hdl(InHandle);
v8::Local<v8::Value> args[1] = {v8::String::NewFromUtf8(
Isolate, con->get_ec().message().c_str(), v8::NewStringType::kNormal, con->get_ec().message().size())
.ToLocalChecked()};
std::stringstream ss;
ss << "on fail: " << con->get_ec().message() << "[" << con->get_ec().value() << "]" << std::endl;
v8::Local<v8::Value> args[1] = {
v8::String::NewFromUtf8(Isolate, ss.str().c_str(), v8::NewStringType::kNormal, ss.str().size()).ToLocalChecked()};
// must not raise exception in js, recommend just push a pending msg and process later.
Handles[ON_FAIL].Get(Isolate)->Call(GContext.Get(Isolate), v8::Undefined(Isolate), 1, args);
}
Expand Down

0 comments on commit ee32720

Please sign in to comment.