{"action":"created","comment":{"url":"https://api.github.com/repos/square/duktape-android/pulls/comments/59134431","id":59134431,"diff_hunk":"@@ -93,6 +93,45 @@ duk_ret_t javaObjectFinalizer(duk_context *ctx) {\n   return 0;\n }\n \n+void handleJavaScriptError(JNIEnv* env, duk_context* ctx) {\n+  jclass exceptionClass = env->FindClass(\"com/squareup/duktape/DuktapeException\");\n+\n+  // If it's a Duktape error object, try to pull out the full stacktrace.\n+  if (duk_is_error(ctx, -1) && duk_get_prop_string(ctx, -1, \"stack\")) {\n+    const char* stack = duk_safe_to_string(ctx, -1);\n+\n+    // Is there an exception thrown from a Java method?\n+    if (duk_get_prop_string(ctx, -2, JavaMethod::JAVA_EXCEPTION_PROP_NAME)) {\n+      jthrowable ex = static_cast<jthrowable>(duk_get_pointer(ctx, -1));\n+\n+      // add the Duktape JavaScript stack to this exception.\n+      const jmethodID addDuktapeStack =\n+          env->GetStaticMethodID(exceptionClass,\n+                                 \"addDuktapeStack\",\n+                                 \"(Ljava/lang/Throwable;Ljava/lang/String;)V\");\n+      env->CallStaticVoidMethod(exceptionClass, addDuktapeStack, ex, env->NewStringUTF(stack));\n+\n+      // Rethrow the Java exception.\n+      env->Throw(ex);\n+\n+      // Pop the Java throwable.\n+      duk_pop(ctx);\n+    } else {\n+      env->ThrowNew(exceptionClass, stack);\n+    }\n+    // Pop the stack text.\n+    duk_pop(ctx);\n+  } else {\n+    // Not an error or no stacktrace, just convert to a string.\n+    env->ThrowNew(exceptionClass, duk_safe_to_string(ctx, -1));\n+  }\n+}\n+\n+void throwNoSuchMethod(JNIEnv* env, const std::string& message) {","path":"duktape/src/main/jni/DuktapeContext.cpp","position":38,"original_position":38,"commit_id":"829513126263bbc0373db06531108a8d73b00603","original_commit_id":"829513126263bbc0373db06531108a8d73b00603","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars.githubusercontent.com/u/133019?v=3","gravatar_id":"","url":"https://api.github.com/users/swankjesse","html_url":"https://github.com/swankjesse","followers_url":"https://api.github.com/users/swankjesse/followers","following_url":"https://api.github.com/users/swankjesse/following{/other_user}","gists_url":"https://api.github.com/users/swankjesse/gists{/gist_id}","starred_url":"https://api.github.com/users/swankjesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swankjesse/subscriptions","organizations_url":"https://api.github.com/users/swankjesse/orgs","repos_url":"https://api.github.com/users/swankjesse/repos","events_url":"https://api.github.com/users/swankjesse/events{/privacy}","received_events_url":"https://api.github.com/users/swankjesse/received_events","type":"User","site_admin":false},"body":"Having a rule like _“We always throw DuktapeException when your Java and JavaScript disagree”_ is easy to work with.","created_at":"2016-04-10T14:01:35Z","updated_at":"2016-04-10T14:01:35Z","html_url":"https://github.com/square/duktape-android/pull/46#discussion_r59134431","pull_request_url":"https://api.github.com/repos/square/duktape-android/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/square/duktape-android/pulls/comments/59134431"},"html":{"href":"https://github.com/square/duktape-android/pull/46#discussion_r59134431"},"pull_request":{"href":"https://api.github.com/repos/square/duktape-android/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/square/duktape-android/pulls/46","id":65900112,"html_url":"https://github.com/square/duktape-android/pull/46","diff_url":"https://github.com/square/duktape-android/pull/46.diff","patch_url":"https://github.com/square/duktape-android/pull/46.patch","issue_url":"https://api.github.com/repos/square/duktape-android/issues/46","number":46,"state":"open","locked":false,"title":"Initial implementation of proxy support.","user":{"login":"szurbrigg","id":13789594,"avatar_url":"https://avatars.githubusercontent.com/u/13789594?v=3","gravatar_id":"","url":"https://api.github.com/users/szurbrigg","html_url":"https://github.com/szurbrigg","followers_url":"https://api.github.com/users/szurbrigg/followers","following_url":"https://api.github.com/users/szurbrigg/following{/other_user}","gists_url":"https://api.github.com/users/szurbrigg/gists{/gist_id}","starred_url":"https://api.github.com/users/szurbrigg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szurbrigg/subscriptions","organizations_url":"https://api.github.com/users/szurbrigg/orgs","repos_url":"https://api.github.com/users/szurbrigg/repos","events_url":"https://api.github.com/users/szurbrigg/events{/privacy}","received_events_url":"https://api.github.com/users/szurbrigg/received_events","type":"User","site_admin":false},"body":"- support a proxy method that allows Java to call a global JavaScript\r\n  object.\r\n- still a work in progress: no argument support, only strings for return\r\n  values.\r\n- misc: split up the tests into separate fixtures by functional group.","created_at":"2016-04-10T03:48:20Z","updated_at":"2016-04-10T14:01:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ca3098aaf59bd4c4c28f63eb8eb5aa3ad96db34","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/duktape-android/pulls/46/commits","review_comments_url":"https://api.github.com/repos/square/duktape-android/pulls/46/comments","review_comment_url":"https://api.github.com/repos/square/duktape-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/duktape-android/issues/46/comments","statuses_url":"https://api.github.com/repos/square/duktape-android/statuses/829513126263bbc0373db06531108a8d73b00603","head":{"label":"square:szurbrigg/0409-duktape-js-proxy","ref":"szurbrigg/0409-duktape-js-proxy","sha":"829513126263bbc0373db06531108a8d73b00603","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":41445081,"name":"duktape-android","full_name":"square/duktape-android","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/duktape-android","description":"The Duktape embeddable Javascript engine packaged for Android.","fork":false,"url":"https://api.github.com/repos/square/duktape-android","forks_url":"https://api.github.com/repos/square/duktape-android/forks","keys_url":"https://api.github.com/repos/square/duktape-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/duktape-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/duktape-android/teams","hooks_url":"https://api.github.com/repos/square/duktape-android/hooks","issue_events_url":"https://api.github.com/repos/square/duktape-android/issues/events{/number}","events_url":"https://api.github.com/repos/square/duktape-android/events","assignees_url":"https://api.github.com/repos/square/duktape-android/assignees{/user}","branches_url":"https://api.github.com/repos/square/duktape-android/branches{/branch}","tags_url":"https://api.github.com/repos/square/duktape-android/tags","blobs_url":"https://api.github.com/repos/square/duktape-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/duktape-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/duktape-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/duktape-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/duktape-android/statuses/{sha}","languages_url":"https://api.github.com/repos/square/duktape-android/languages","stargazers_url":"https://api.github.com/repos/square/duktape-android/stargazers","contributors_url":"https://api.github.com/repos/square/duktape-android/contributors","subscribers_url":"https://api.github.com/repos/square/duktape-android/subscribers","subscription_url":"https://api.github.com/repos/square/duktape-android/subscription","commits_url":"https://api.github.com/repos/square/duktape-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/duktape-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/duktape-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/duktape-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/duktape-android/contents/{+path}","compare_url":"https://api.github.com/repos/square/duktape-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/duktape-android/merges","archive_url":"https://api.github.com/repos/square/duktape-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/duktape-android/downloads","issues_url":"https://api.github.com/repos/square/duktape-android/issues{/number}","pulls_url":"https://api.github.com/repos/square/duktape-android/pulls{/number}","milestones_url":"https://api.github.com/repos/square/duktape-android/milestones{/number}","notifications_url":"https://api.github.com/repos/square/duktape-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/duktape-android/labels{/name}","releases_url":"https://api.github.com/repos/square/duktape-android/releases{/id}","deployments_url":"https://api.github.com/repos/square/duktape-android/deployments","created_at":"2015-08-26T19:17:25Z","updated_at":"2016-04-07T10:25:15Z","pushed_at":"2016-04-10T04:20:06Z","git_url":"git://github.com/square/duktape-android.git","ssh_url":"git@github.com:square/duktape-android.git","clone_url":"https://github.com/square/duktape-android.git","svn_url":"https://github.com/square/duktape-android","homepage":"","size":2537,"stargazers_count":263,"watchers_count":263,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":15,"mirror_url":null,"open_issues_count":5,"forks":15,"open_issues":5,"watchers":263,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"a9dbb9ab4191b366c461e5154d4d9d20b5e134ce","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":41445081,"name":"duktape-android","full_name":"square/duktape-android","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/duktape-android","description":"The Duktape embeddable Javascript engine packaged for Android.","fork":false,"url":"https://api.github.com/repos/square/duktape-android","forks_url":"https://api.github.com/repos/square/duktape-android/forks","keys_url":"https://api.github.com/repos/square/duktape-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/duktape-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/duktape-android/teams","hooks_url":"https://api.github.com/repos/square/duktape-android/hooks","issue_events_url":"https://api.github.com/repos/square/duktape-android/issues/events{/number}","events_url":"https://api.github.com/repos/square/duktape-android/events","assignees_url":"https://api.github.com/repos/square/duktape-android/assignees{/user}","branches_url":"https://api.github.com/repos/square/duktape-android/branches{/branch}","tags_url":"https://api.github.com/repos/square/duktape-android/tags","blobs_url":"https://api.github.com/repos/square/duktape-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/duktape-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/duktape-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/duktape-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/duktape-android/statuses/{sha}","languages_url":"https://api.github.com/repos/square/duktape-android/languages","stargazers_url":"https://api.github.com/repos/square/duktape-android/stargazers","contributors_url":"https://api.github.com/repos/square/duktape-android/contributors","subscribers_url":"https://api.github.com/repos/square/duktape-android/subscribers","subscription_url":"https://api.github.com/repos/square/duktape-android/subscription","commits_url":"https://api.github.com/repos/square/duktape-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/duktape-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/duktape-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/duktape-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/duktape-android/contents/{+path}","compare_url":"https://api.github.com/repos/square/duktape-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/duktape-android/merges","archive_url":"https://api.github.com/repos/square/duktape-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/duktape-android/downloads","issues_url":"https://api.github.com/repos/square/duktape-android/issues{/number}","pulls_url":"https://api.github.com/repos/square/duktape-android/pulls{/number}","milestones_url":"https://api.github.com/repos/square/duktape-android/milestones{/number}","notifications_url":"https://api.github.com/repos/square/duktape-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/duktape-android/labels{/name}","releases_url":"https://api.github.com/repos/square/duktape-android/releases{/id}","deployments_url":"https://api.github.com/repos/square/duktape-android/deployments","created_at":"2015-08-26T19:17:25Z","updated_at":"2016-04-07T10:25:15Z","pushed_at":"2016-04-10T04:20:06Z","git_url":"git://github.com/square/duktape-android.git","ssh_url":"git@github.com:square/duktape-android.git","clone_url":"https://github.com/square/duktape-android.git","svn_url":"https://github.com/square/duktape-android","homepage":"","size":2537,"stargazers_count":263,"watchers_count":263,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":15,"mirror_url":null,"open_issues_count":5,"forks":15,"open_issues":5,"watchers":263,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/duktape-android/pulls/46"},"html":{"href":"https://github.com/square/duktape-android/pull/46"},"issue":{"href":"https://api.github.com/repos/square/duktape-android/issues/46"},"comments":{"href":"https://api.github.com/repos/square/duktape-android/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/square/duktape-android/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/square/duktape-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/duktape-android/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/square/duktape-android/statuses/829513126263bbc0373db06531108a8d73b00603"}}}}