MCPcopy
hub / github.com/angular-ui/ui-grid / minErr

Function minErr

lib/test/angular/1.6.7/angular.js:88–118  ·  view source on GitHub ↗

* @description * * This object provides a utility for producing rich Error messages within * Angular. It can be called as follows: * * var exampleMinErr = minErr('example'); * throw exampleMinErr('one', 'This {0} is {1}', foo, bar); * * The above creates an instance of minErr in the example

(module, ErrorConstructor)

Source from the content-addressed store, hash-verified

86 */
87
88function minErr(module, ErrorConstructor) {
89 ErrorConstructor = ErrorConstructor || Error;
90 return function() {
91 var code = arguments[0],
92 template = arguments[1],
93 message = '[' + (module ? module + ':' : '') + code + '] ',
94 templateArgs = sliceArgs(arguments, 2).map(function(arg) {
95 return toDebugString(arg, minErrConfig.objectMaxDepth);
96 }),
97 paramPrefix, i;
98
99 message += template.replace(/\{\d+\}/g, function(match) {
100 var index = +match.slice(1, -1);
101
102 if (index < templateArgs.length) {
103 return templateArgs[index];
104 }
105
106 return match;
107 });
108
109 message += '\nhttp://errors.angularjs.org/1.6.7/' +
110 (module ? module + '/' : '') + code;
111
112 for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
113 message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]);
114 }
115
116 return new ErrorConstructor(message);
117 };
118}
119
120/* We need to tell ESLint what variables are being exported */
121/* exported

Callers 10

angular.jsFile · 0.70
setupModuleLoaderFunction · 0.70
cacheFactoryFunction · 0.70
addIdentifierFunction · 0.70
$httpFunction · 0.70
qFactoryFunction · 0.70
$RootScopeProviderFunction · 0.70
filterFilterFunction · 0.70
orderByFilterFunction · 0.70
patternDirectiveFunction · 0.70

Calls 2

sliceArgsFunction · 0.70
toDebugStringFunction · 0.70

Tested by

no test coverage detected