From c1ee16b8dd82da24b6ef2675bd09b2893efa72db Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Mon, 8 Jul 2013 11:42:31 +0100 Subject: [PATCH 1/3] chore(resource): use minErr to throw exception --- src/ngResource/resource.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 827886a3cbd9..d5800b748369 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -1,5 +1,7 @@ 'use strict'; +var ngResourceMinErr = minErr('ngResource'); + /** * @ngdoc overview * @name ngResource @@ -448,8 +450,8 @@ angular.module('ngResource', ['ng']). break; case 0: break; default: - throw "Expected up to 4 arguments [params, data, success, error], got " + - arguments.length + " arguments."; + throw ngResourceMinErr('badargs', + "Expected up to 4 arguments [params, data, success, error], got {0} arguments", arguments.length); } var isInstanceCall = data instanceof Resource; From 77c9f54d3974fbbb99eac785b255b29dc948b2b7 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Mon, 8 Jul 2013 13:23:45 +0100 Subject: [PATCH 2/3] chore(sanitize): use minErr to throw exception --- src/ngSanitize/sanitize.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index 30de2231bf0f..e82c494946f6 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -1,5 +1,7 @@ 'use strict'; +var ngSanitizeMinErr = minErr('ngSanitize'); + /** * @ngdoc overview * @name ngSanitize @@ -269,7 +271,7 @@ function htmlParser( html, handler ) { } if ( html == last ) { - throw "Parse Error: " + html; + throw ngSanitizeMinErr('badparse', "The sanitizer was unable to parse the following block of html: {0}", html); } last = html; } From d557f80114ec824de6cc0aed6a43ada6e1f4cbce Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Mon, 8 Jul 2013 14:42:18 +0100 Subject: [PATCH 3/3] feat(Angular): provide minErr as public property This allows us to use minErr in other modules, such as resource and sanitize. --- src/AngularPublic.js | 1 + src/ngResource/resource.js | 2 +- src/ngSanitize/sanitize.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AngularPublic.js b/src/AngularPublic.js index 53ad5aabfb4f..6c0acb87f323 100755 --- a/src/AngularPublic.js +++ b/src/AngularPublic.js @@ -44,6 +44,7 @@ function publishExternalAPI(angular){ 'isNumber': isNumber, 'isElement': isElement, 'isArray': isArray, + 'minErr': minErr, 'version': version, 'isDate': isDate, 'lowercase': lowercase, diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index d5800b748369..ce0aaa1790a8 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -1,6 +1,6 @@ 'use strict'; -var ngResourceMinErr = minErr('ngResource'); +var ngResourceMinErr = angular.minErr('ngResource'); /** * @ngdoc overview diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index e82c494946f6..0ee25e08978e 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -1,6 +1,6 @@ 'use strict'; -var ngSanitizeMinErr = minErr('ngSanitize'); +var ngSanitizeMinErr = angular.minErr('ngSanitize'); /** * @ngdoc overview