MCPcopy Create free account
hub / github.com/NativeScript/android / assertCallback

Method assertCallback

test-app/runtime/src/main/cpp/console/Console.cpp:174–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174void Console::assertCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
175 try {
176 auto isolate = info.GetIsolate();
177
178 auto argLen = info.Length();
179 auto expressionPasses = argLen && info[0]->BooleanValue(isolate);
180
181 if (!expressionPasses) {
182 std::stringstream assertionError;
183
184 assertionError << "Assertion failed: ";
185
186 if (argLen > 1) {
187 assertionError << buildLogString(info, 1);
188 } else {
189 assertionError << "console.assert";
190 }
191
192 std::string log = assertionError.str();
193 sendToADBLogcat(log, ANDROID_LOG_ERROR);
194 sendToDevToolsFrontEnd(isolate, ConsoleAPIType::kAssert, info);
195 }
196 } catch (NativeScriptException& e) {
197 e.ReThrowToV8();
198 } catch (std::exception e) {
199 std::stringstream ss;
200 ss << "Error: c++ exception: " << e.what() << std::endl;
201 NativeScriptException nsEx(ss.str());
202 nsEx.ReThrowToV8();
203 } catch (...) {
204 NativeScriptException nsEx(std::string("Error: c++ exception!"));
205 nsEx.ReThrowToV8();
206 }
207}
208
209void Console::errorCallback(const v8::FunctionCallbackInfo <v8::Value>& info) {
210 try {

Callers

nothing calls this directly

Calls 6

buildLogStringFunction · 0.85
BooleanValueMethod · 0.80
ReThrowToV8Method · 0.80
GetIsolateMethod · 0.45
LengthMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected