@@ -79,7 +79,6 @@ function isValidObjectMaxDepth(maxDepth) {
79
79
* error from returned function, for cases when a particular type of error is useful.
80
80
* @returns {function(code:string, template:string, ...templateArgs): Error } minErr instance
81
81
*/
82
-
83
82
function minErr ( module , ErrorConstructor ) {
84
83
ErrorConstructor = ErrorConstructor || Error ;
85
84
return function ( ) {
@@ -111,3 +110,38 @@ function minErr(module, ErrorConstructor) {
111
110
return new ErrorConstructor ( message ) ;
112
111
} ;
113
112
}
113
+
114
+ /**
115
+ * @description
116
+ *
117
+ * In certain case (e.g. when catching and rethrowing an error), it is neither desirable nor
118
+ * necessary to pass the error through `minErr()`. You can use this function to avoid warnings
119
+ * produced by `ng-closire-runner` during `grunt minall`.
120
+ *
121
+ * Due to what arguments `ng-closure-runner` expects, the first two arguments must be static
122
+ * strings. Therefore, you have to pass the actual error as 3rd argument (see example below).
123
+ *
124
+ * **WARNING**
125
+ * Only use this function when you are certain that the thrown error should NOT be a `minErr`
126
+ * instance;
127
+ *
128
+ * Example usage:
129
+ *
130
+ * ```js
131
+ * try {
132
+ * tryAndFail();
133
+ * } catch (err) {
134
+ * doSomeThing(err);
135
+ * throw noMinErr('', '', err); // Functionally equivalent to `throw err`,
136
+ * // but avoids `ng-closure-runner` warnings.
137
+ * }
138
+ * ```
139
+ *
140
+ * @param {string } ignoredCode - Ignored, but necessary for `ng-closure-runner`.
141
+ * @param {string } ignoredTemplate - Ignored, but necessary for `ng-closure-runner`.
142
+ * @param {* } error - The error object that will be returned.
143
+ * @returns {* } - The passed in error.
144
+ */
145
+ function noMinErr ( ignoredCode , ignoredTemplate , err ) {
146
+ return err ;
147
+ }
0 commit comments