MCPcopy Create free account
hub / github.com/OpenReservation/OpenReservation / minErr

Function minErr

OpenReservation/wwwroot/Scripts/angular.js:39–77  ·  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 in

(module, ErrorConstructor)

Source from the content-addressed store, hash-verified

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

Callers 10

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

Calls 1

toDebugStringFunction · 0.85

Tested by

no test coverage detected