@@ 152-182 (lines=31) @@ | ||
149 | * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance |
|
150 | */ |
|
151 | ||
152 | function minErr(module, ErrorConstructor) { |
|
153 | ErrorConstructor = ErrorConstructor || Error; |
|
154 | return function() { |
|
155 | var code = arguments[0], |
|
156 | template = arguments[1], |
|
157 | message = '[' + (module ? module + ':' : '') + code + '] ', |
|
158 | templateArgs = sliceArgs(arguments, 2).map(function(arg) { |
|
159 | return toDebugString(arg, minErrConfig.objectMaxDepth); |
|
160 | }), |
|
161 | paramPrefix, i; |
|
162 | ||
163 | message += template.replace(/\{\d+\}/g, function(match) { |
|
164 | var index = +match.slice(1, -1); |
|
165 | ||
166 | if (index < templateArgs.length) { |
|
167 | return templateArgs[index]; |
|
168 | } |
|
169 | ||
170 | return match; |
|
171 | }); |
|
172 | ||
173 | message += '\nhttp://errors.angularjs.org/1.6.5/' + |
|
174 | (module ? module + '/' : '') + code; |
|
175 | ||
176 | for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') { |
|
177 | message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]); |
|
178 | } |
|
179 | ||
180 | return new ErrorConstructor(message); |
|
181 | }; |
|
182 | } |
|
183 | ||
184 | /** |
|
185 | * @ngdoc type |
@@ 76-106 (lines=31) @@ | ||
73 | * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance |
|
74 | */ |
|
75 | ||
76 | function minErr(module, ErrorConstructor) { |
|
77 | ErrorConstructor = ErrorConstructor || Error; |
|
78 | return function() { |
|
79 | var code = arguments[0], |
|
80 | template = arguments[1], |
|
81 | message = '[' + (module ? module + ':' : '') + code + '] ', |
|
82 | templateArgs = sliceArgs(arguments, 2).map(function(arg) { |
|
83 | return toDebugString(arg, minErrConfig.objectMaxDepth); |
|
84 | }), |
|
85 | paramPrefix, i; |
|
86 | ||
87 | message += template.replace(/\{\d+\}/g, function(match) { |
|
88 | var index = +match.slice(1, -1); |
|
89 | ||
90 | if (index < templateArgs.length) { |
|
91 | return templateArgs[index]; |
|
92 | } |
|
93 | ||
94 | return match; |
|
95 | }); |
|
96 | ||
97 | message += '\nhttp://errors.angularjs.org/1.6.4/' + |
|
98 | (module ? module + '/' : '') + code; |
|
99 | ||
100 | for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') { |
|
101 | message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]); |
|
102 | } |
|
103 | ||
104 | return new ErrorConstructor(message); |
|
105 | }; |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * @ngdoc type |