|
4 | 4 |
|
5 | 5 | #include <sstream>
|
6 | 6 | #include "NetworkDomainCallbackHandlers.h"
|
| 7 | +#include "NativeScriptAssert.h" |
7 | 8 |
|
8 | 9 | using namespace tns;
|
9 | 10 |
|
@@ -48,14 +49,24 @@ void NetworkDomainCallbackHandlers::ResponseReceivedCallback(const v8::FunctionC
|
48 | 49 | throw NativeScriptException("`response` parameter not in the correct format.");
|
49 | 50 | }
|
50 | 51 |
|
51 |
| - auto responseJsonString = ArgConverter::ConvertToString(responseJson).c_str(); |
52 |
| - auto protocolResponseJson = protocol::parseJSON(responseJsonString); |
| 52 | + auto responseJsonString = ArgConverter::ConvertToString(responseJson); |
| 53 | + auto responseJsonCString = responseJsonString.c_str(); |
| 54 | + auto protocolResponseJson = protocol::parseJSON(responseJsonCString); |
53 | 55 |
|
54 | 56 | protocol::ErrorSupport errorSupport;
|
55 | 57 |
|
56 | 58 | auto protocolResponseObj = protocol::Network::Response::parse(protocolResponseJson.get(),
|
57 | 59 | &errorSupport);
|
58 | 60 |
|
| 61 | + auto errorString = errorSupport.errors().utf8(); |
| 62 | + |
| 63 | + if (!errorString.empty()) { |
| 64 | + auto errorMessage = "Error while parsing debug `response` object. "; |
| 65 | + DEBUG_WRITE_FORCE("%s Error: %s", errorMessage, errorString.c_str()); |
| 66 | + |
| 67 | + throw NativeScriptException(errorMessage + errorString); |
| 68 | + } |
| 69 | + |
59 | 70 | auto requestIdString = ArgConverter::ConvertToString(requestId).c_str();
|
60 | 71 | auto networkRequestData = new v8_inspector::utils::NetworkRequestData();
|
61 | 72 | networkAgentInstance->m_responses.insert(std::make_pair(requestIdString, networkRequestData));
|
@@ -122,21 +133,31 @@ void NetworkDomainCallbackHandlers::RequestWillBeSentCallback(const v8::Function
|
122 | 133 | throw NativeScriptException("`request` parameter not in the correct format.");
|
123 | 134 | }
|
124 | 135 |
|
125 |
| - auto requestJsonString = ArgConverter::ConvertToString(requestJson).c_str(); |
126 |
| - auto protocolRequestJson = protocol::parseJSON(requestJsonString); |
| 136 | + auto requestJsonString = ArgConverter::ConvertToString(requestJson); |
| 137 | + auto requestJsonCString = requestJsonString.c_str(); |
| 138 | + auto protocolRequestJson = protocol::parseJSON(requestJsonCString); |
127 | 139 |
|
128 | 140 | protocol::ErrorSupport errorSupport;
|
129 | 141 |
|
130 |
| - auto protocolResponseObj = protocol::Network::Request::parse(protocolRequestJson.get(), &errorSupport); |
| 142 | + auto protocolRequestObj = protocol::Network::Request::parse(protocolRequestJson.get(), &errorSupport); |
131 | 143 | auto initiator = protocol::Network::Initiator::create().setType(protocol::Network::Initiator::TypeEnum::Script).build();
|
132 | 144 |
|
| 145 | + auto errorString = errorSupport.errors().utf8(); |
| 146 | + |
| 147 | + if (!errorString.empty()) { |
| 148 | + auto errorMessage = "Error while parsing debug `request` object. "; |
| 149 | + DEBUG_WRITE_FORCE("%s Error: %s", errorMessage, errorString.c_str()); |
| 150 | + |
| 151 | + throw NativeScriptException(errorMessage + errorString); |
| 152 | + } |
| 153 | + |
133 | 154 | protocol::Maybe<String16> type(ArgConverter::ConvertToString(typeArg).c_str());
|
134 | 155 | protocol::Maybe<protocol::Network::Response> emptyRedirect;
|
135 | 156 | networkAgentInstance->m_frontend.requestWillBeSent(ArgConverter::ConvertToString(requestId).c_str(),
|
136 | 157 | FrameId,
|
137 | 158 | LoaderId,
|
138 | 159 | ArgConverter::ConvertToString(url).c_str(),
|
139 |
| - std::move(protocolResponseObj), |
| 160 | + std::move(protocolRequestObj), |
140 | 161 | timeStamp,
|
141 | 162 | std::move(initiator),
|
142 | 163 | emptyRedirect,
|
|
0 commit comments