{"id":22013953,"url":"https://github.com/pmuellr/log-callback-error","last_synced_at":"2025-07-24T00:06:23.721Z","repository":{"id":66666030,"uuid":"2555468","full_name":"pmuellr/log-callback-error","owner":"pmuellr","description":"logs callback errors in JavaScript functions for mobile browsers","archived":false,"fork":false,"pushed_at":"2011-10-11T13:42:45.000Z","size":94,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-06T22:15:15.309Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmuellr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-11T13:37:21.000Z","updated_at":"2022-12-15T22:36:20.000Z","dependencies_parsed_at":"2023-02-20T08:45:53.129Z","dependency_job_id":null,"html_url":"https://github.com/pmuellr/log-callback-error","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pmuellr/log-callback-error","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Flog-callback-error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Flog-callback-error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Flog-callback-error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Flog-callback-error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmuellr","download_url":"https://codeload.github.com/pmuellr/log-callback-error/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Flog-callback-error/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266770717,"owners_count":23981613,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T03:25:40.420Z","updated_at":"2025-07-24T00:06:23.696Z","avatar_url":"https://github.com/pmuellr.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"log-callback-error\n==================\n\nA set of overrides to existing JavaScript functions that take callbacks,\nwhich will log an error if an exception is thrown during the invocation of\nthe callback.\n\nThis is aimed primarily for mobile browser engines.\n\nthe problem\n-----------\n\nOn the desktop today, to track down runtime exceptions that are occurring in\nyour JavaScript code, it's fairly easy to bring up a \"web debugger\" like Web\nInspector or FireBug, and have it show you where the error occurred.\n\nFor mobile platforms, well, we have a problem, because we don't have robust\nJavaScript debug capability available.  In fact, often, you have no idea that\nany runtime error occurred at all, besides the sneaking feeling that your\napplication \"just isn't working right\".\n\nsome help\n---------\n\nIn lieu of this missing function, there's this library.  It instruments a\nnumber of built-in JavaScript functions which take callbacks, and will run\nthose callbacks in a try/catch.  It will then report the exception to you via\n`console.log()`.  In addition, it will display a little bit of context about\nthe function invocation that specified the callback, as this may help you\nfurther narrow down the problem.\n\nFor instance, if you open the file `test/tests.html` in a browser, and\nclick on the button `setTimeout`, it will run a `setTimeout()` function with a\ncallback that causes a runtime exception.  You should then see the following\nin the console:\n\n    exception executing callback: TypeError: Cannot set property 'x' of null\n        callsite:   setTimeout(callbackWithError, 500)\n        stacktrace follows\n    TypeError: Cannot set property 'x' of null\n        at functionThatThrowsError (http://example.com/log-callback-error/test/tests.js:80:9)\n        at callbackWithError (http://example.com/log-callback-error/test/tests.js:74:5)\n        at http://example.com/log-callback-error/log-callback-error.js:65:21\n\nNote that you'll only see the stacktrace if your browser supports the `stack`\nproperty on exceptions (at least Opera and V8-enabled browsers; Safari flavors\ndo not yet support the `stack` property).\n\nThe stacktrace is the stack at the time the exception occurred.\n\nThe second line of the output, labelled with `callsite`,\nis the *context* of the call.  It provides\nsome information about how the callback was initially registered.  In the case\nabove, it provides the name of the callback function registered, along with\nthe timeout millisecond value.\n\nusage\n-----\n\nAdd the line\n\n    \u003cscript src=\"log-callback-error.js\"\u003e\u003c/script\u003e\n\nbefore any other JavaScript files in your HTML files.\n\nfunctions overridden\n--------------------\n\nThe following functions are overridden to provide the exception callback\nhandling:\n\n    window.setTimeout()\n    window.setInterval()\n    window.addEventListener()\n    Node.prototype.addEventListener()\n    XMLHttpRequest.prototype.addEventListener()\n\nThe `Node.prototype.addEventListener()` override applies to all DOM nodes,\nincluding `document`.  The `XMLHttpRequest` flavor applies to all XHR\nrequests.\n\nSpecifically note, these are the only things overridden.  Need more?  Fork,\nadd, push.\n\nIt seems likely that the `onblahblah` flavored event properties will never\nbe supported, because the DOM host objects suck.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmuellr%2Flog-callback-error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmuellr%2Flog-callback-error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmuellr%2Flog-callback-error/lists"}