1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export var ERROR_TYPE = 'ngType';
|
9 | export var ERROR_COMPONENT_TYPE = 'ngComponentType';
|
10 | export var ERROR_DEBUG_CONTEXT = 'ngDebugContext';
|
11 | export var ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
12 | export var ERROR_LOGGER = 'ngErrorLogger';
|
13 | export function getType(error) {
|
14 | return error[ERROR_TYPE];
|
15 | }
|
16 | export function getDebugContext(error) {
|
17 | return error[ERROR_DEBUG_CONTEXT];
|
18 | }
|
19 | export function getOriginalError(error) {
|
20 | return error[ERROR_ORIGINAL_ERROR];
|
21 | }
|
22 | function 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 | }
|
29 | export function getErrorLogger(error) {
|
30 | return error[ERROR_LOGGER] || defaultErrorLogger;
|
31 | }
|
32 | export 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 |
|
\ | No newline at end of file |