forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.ts
More file actions
29 lines (27 loc) · 1.01 KB
/
logging.ts
File metadata and controls
29 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
export function formatErrorForLogging(error: Error | string): string {
let message: string = '';
if (typeof error === 'string') {
message = error;
} else {
if (error.message) {
message = `Error Message: ${error.message}`;
}
if (error.name && error.message.indexOf(error.name) === -1) {
message += `, (${error.name})`;
}
// tslint:disable-next-line:no-any
const innerException = (error as any).innerException;
if (innerException && (innerException.message || innerException.name)) {
if (innerException.message) {
message += `, Inner Error Message: ${innerException.message}`;
}
if (innerException.name && innerException.message.indexOf(innerException.name) === -1) {
message += `, (${innerException.name})`;
}
}
}
return message;
}