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

Function minErr

test/angular/1.4/angular.js:38–70  ·  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

36 */
37
38function minErr(module, ErrorConstructor) {
39 ErrorConstructor = ErrorConstructor || Error;
40 return function() {
41 var SKIP_INDEXES = 2;
42
43 var templateArgs = arguments,
44 code = templateArgs[0],
45 message = '[' + (module ? module + ':' : '') + code + '] ',
46 template = templateArgs[1],
47 paramPrefix, i;
48
49 message += template.replace(/\{\d+\}/g, function(match) {
50 var index = +match.slice(1, -1),
51 shiftedIndex = index + SKIP_INDEXES;
52
53 if (shiftedIndex < templateArgs.length) {
54 return toDebugString(templateArgs[shiftedIndex]);
55 }
56
57 return match;
58 });
59
60 message += '\nhttp://errors.angularjs.org/1.4.14/' +
61 (module ? module + '/' : '') + code;
62
63 for (i = SKIP_INDEXES, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
64 message += paramPrefix + 'p' + (i - SKIP_INDEXES) + '=' +
65 encodeURIComponent(toDebugString(templateArgs[i]));
66 }
67
68 return new ErrorConstructor(message);
69 };
70}
71
72/* We need to tell jshint what variables are being exported */
73/* global angular: true,

Callers 9

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
patternDirectiveFunction · 0.70

Calls 1

toDebugStringFunction · 0.70

Tested by

no test coverage detected