UNPKG

1.27 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8export var ERROR_TYPE = 'ngType';
9export var ERROR_COMPONENT_TYPE = 'ngComponentType';
10export var ERROR_DEBUG_CONTEXT = 'ngDebugContext';
11export var ERROR_ORIGINAL_ERROR = 'ngOriginalError';
12export var ERROR_LOGGER = 'ngErrorLogger';
13export function getType(error) {
14 return error[ERROR_TYPE];
15}
16export function getDebugContext(error) {
17 return error[ERROR_DEBUG_CONTEXT];
18}
19export function getOriginalError(error) {
20 return error[ERROR_ORIGINAL_ERROR];
21}
22function defaultErrorLogger(console) {
23 var values = [];
24 for (var _i = 1; _i < arguments.length; _i++) {
25 values[_i - 1] = arguments[_i];
26 }
27 console.error.apply(console, values);
28}
29export function getErrorLogger(error) {
30 return error[ERROR_LOGGER] || defaultErrorLogger;
31}
32export function wrappedError(message, originalError) {
33 var msg = message + " caused by: " + (originalError instanceof Error ? originalError.message : originalError);
34 var error = Error(msg);
35 error[ERROR_ORIGINAL_ERROR] = originalError;
36 return error;
37}
38//# sourceMappingURL=errors.js.map
\No newline at end of file