injection-js
Version:
Dependency Injection library for JavaScript and TypeScript
38 lines • 1.27 kB
JavaScript
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
export var ERROR_TYPE = 'ngType';
export var ERROR_COMPONENT_TYPE = 'ngComponentType';
export var ERROR_DEBUG_CONTEXT = 'ngDebugContext';
export var ERROR_ORIGINAL_ERROR = 'ngOriginalError';
export var ERROR_LOGGER = 'ngErrorLogger';
export function getType(error) {
return error[ERROR_TYPE];
}
export function getDebugContext(error) {
return error[ERROR_DEBUG_CONTEXT];
}
export function getOriginalError(error) {
return error[ERROR_ORIGINAL_ERROR];
}
function defaultErrorLogger(console) {
var values = [];
for (var _i = 1; _i < arguments.length; _i++) {
values[_i - 1] = arguments[_i];
}
console.error.apply(console, values);
}
export function getErrorLogger(error) {
return error[ERROR_LOGGER] || defaultErrorLogger;
}
export function wrappedError(message, originalError) {
var msg = message + " caused by: " + (originalError instanceof Error ? originalError.message : originalError);
var error = Error(msg);
error[ERROR_ORIGINAL_ERROR] = originalError;
return error;
}
//# sourceMappingURL=errors.js.map