| 172 | } |
| 173 | |
| 174 | void 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 | |
| 209 | void Console::errorCallback(const v8::FunctionCallbackInfo <v8::Value>& info) { |
| 210 | try { |
nothing calls this directly
no test coverage detected