Add information about the cordovacallbackerror event (#1018)
Also see https://github.com/apache/cordova-js/pull/211
diff --git a/www/docs/en/dev/cordova/events/events.md b/www/docs/en/dev/cordova/events/events.md
index af5b0bd..6aa8c1b 100644
--- a/www/docs/en/dev/cordova/events/events.md
+++ b/www/docs/en/dev/cordova/events/events.md
@@ -73,7 +73,10 @@
// Handle the menubutton event
}
-// Add similar event handlers for other events
+// listen for uncaught cordova callback errors
+window.addEventListener("cordovacallbackerror", function (event) {
+ // event.error contains the original error object
+});
```
**Note**: Applications typically should use `document.addEventListener` to attach an event listener once the [deviceready](#deviceready)
@@ -170,6 +173,13 @@
<td data-col="ios" class="n"></td>
<td data-col="win" class="y"></td>
</tr>
+
+ <tr>
+ <th><a href="#cordovacallbackerror">cordovacallbackerror</a></th>
+ <td data-col="android" class="y"></td>
+ <td data-col="ios" class="y"></td>
+ <td data-col="win" class="y"></td>
+ </tr>
</tbody>
</table>
@@ -452,3 +462,22 @@
[UIApplicationExitsOnSuspend]: http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
[AndroidLifeCycleGuide]: ../../guide/platforms/android/index.html#lifecycle-guide
[MSDNActivatedEvent]: https://msdn.microsoft.com/en-us/library/windows/apps/br212679.aspx
+
+## cordovacallbackerror
+
+This event fires when a native callback (success or error) throws an uncaught error.
+
+This does not stop propagation of the error. (eg. window.onerror event will also fire.)
+
+It is slightly different from the other events. You must listen on the `window` object, not the `document` object.
+
+The `event` object has the following properties:
+- `error`: The original `Error` thrown in the callback.
+
+### Quick Example
+
+```javascript
+window.addEventListener("cordovacallbackerror", function (event) {
+ // event.error contains the original error object
+});
+```