forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorUtils.ts
More file actions
26 lines (23 loc) · 919 Bytes
/
errorUtils.ts
File metadata and controls
26 lines (23 loc) · 919 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { EOL } from 'os';
export class ErrorUtils {
public static outputHasModuleNotInstalledError(moduleName: string, content?: string): boolean {
return content &&
(content!.indexOf(`No module named ${moduleName}`) > 0 ||
content!.indexOf(`No module named '${moduleName}'`) > 0)
? true
: false;
}
}
/**
* Wraps an error with a custom error message, retaining the call stack information.
*/
export class WrappedError extends Error {
constructor(message: string, originalException: Error) {
super(message);
// Retain call stack that trapped the error and rethrows this error.
// Also retain the call stack of the original error.
this.stack = `${new Error('').stack}${EOL}${EOL}${originalException.stack}`;
}
}