Index: ui/file_manager/video_player/js/error_util.js |
diff --git a/ui/file_manager/video_player/js/error_util.js b/ui/file_manager/video_player/js/error_util.js |
index 4bbe2eb22f43b83b4f5e6a09b06af7946168ce49..aa78d980f3be230f892486e4ca922e722386957a 100644 |
--- a/ui/file_manager/video_player/js/error_util.js |
+++ b/ui/file_manager/video_player/js/error_util.js |
@@ -22,19 +22,26 @@ window.onerror = function() { window.JSErrorCount++; }; |
* - Bind this object |
* |
* @param {Object} thisObject Object to be used as this. |
+ * @param {...} var_args Arguments to be bound with the wrapped function. |
* @return {function} Wrapped function. |
*/ |
-Function.prototype.wrap = function(thisObject) { |
+Function.prototype.wrap = function(thisObject, var_args) { |
var func = this; |
var liveStack = (new Error('Stack trace before async call')).stack; |
if (thisObject === undefined) |
thisObject = null; |
+ var boundArguments = Array.prototype.slice.call(arguments, 1); |
- return function wrappedCallback() { |
+ return function wrappedCallback(var_args) { |
hirono
2014/06/05 08:47:42
The name of wrappedCallback is needed?
yoshiki
2014/06/05 14:28:13
It's useful in backtrace.
|
try { |
- return func.apply(thisObject, arguments); |
+ var args = boundArguments.concat(Array.prototype.slice.call(arguments)); |
+ return func.apply(thisObject, args); |
} catch (e) { |
- console.error('Exception happens in callback.', liveStack); |
+ // Some async funcrtion doesn't handle exception correctly. So outputing |
+ // the exception message and stack trace just in case. |
+ // The message will show twice if the caller handles exception correctly. |
+ console.error(e.name + ': ' + e.message, e.stack); |
hirono
2014/06/05 08:47:42
e.stack includes e.name and e.message.
yoshiki
2014/06/05 14:28:13
Done.
|
+ console.info('Exception above happened in callback.', liveStack); |
window.JSErrorCount++; |
throw e; |