MCPcopy Index your code
hub / github.com/angular-ui/ui-router / minErr

Function minErr

test/angular/1.3/angular.js:38–65  ·  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 code = arguments[0],
42 prefix = '[' + (module ? module + ':' : '') + code + '] ',
43 template = arguments[1],
44 templateArgs = arguments,
45
46 message, i;
47
48 message = prefix + template.replace(/\{\d+\}/g, function(match) {
49 var index = +match.slice(1, -1), arg;
50
51 if (index + 2 < templateArgs.length) {
52 return toDebugString(templateArgs[index + 2]);
53 }
54 return match;
55 });
56
57 message = message + '\nhttp://errors.angularjs.org/1.3.20/' +
58 (module ? module + '/' : '') + code;
59 for (i = 2; i < arguments.length; i++) {
60 message = message + (i == 2 ? '?' : '&') + 'p' + (i - 2) + '=' +
61 encodeURIComponent(toDebugString(arguments[i]));
62 }
63 return new ErrorConstructor(message);
64 };
65}
66
67/* We need to tell jshint what variables are being exported */
68/* global angular: true,

Callers 8

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

Calls 1

toDebugStringFunction · 0.70

Tested by

no test coverage detected