aboutsummaryrefslogtreecommitdiffstats
path: root/src/Angular.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/Angular.js')
-rw-r--r--src/Angular.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Angular.js b/src/Angular.js
index cfffab04..1549e7a7 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -181,15 +181,32 @@ function escapeAttr(html) {
function bind(_this, _function) {
var curryArgs = slice.call(arguments, 2, arguments.length);
- if (!_this)
- throw "Missing this";
- if (!_.isFunction(_function))
- throw "Missing function";
return function() {
return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length)));
};
}
+function bindTry(_this, _function) {
+ var args = arguments,
+ last = args.length - 1,
+ curryArgs = slice.call(args, 2, last),
+ exceptionHandler = args[last];
+ return function() {
+ try {
+ return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length)));
+ } catch (e) {
+ if (e = exceptionHandler(e)) throw e;
+ }
+ };
+}
+
+function errorHandlerFor(element) {
+ return function(error){
+ element.attr('ng-error', angular.toJson(error));
+ element.addClass('ng-exception');
+ };
+}
+
function outerHTML(node) {
var temp = document.createElement('div');
temp.appendChild(node);