MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / analyzeKernelErrors

Function analyzeKernelErrors

src/platform/errors/errorUtils.ts:280–602  ·  view source on GitHub ↗
(
    workspaceFolders: readonly WorkspaceFolder[],
    error: Error | string,
    kernelDisplayName: string | undefined,
    pythonSysPrefix: string = '',
    filesInCwd: Uri[] = []
)

Source from the content-addressed store, hash-verified

278 | KernelSessionDisposedFailure;
279
280export function analyzeKernelErrors(
281 workspaceFolders: readonly WorkspaceFolder[],
282 error: Error | string,
283 kernelDisplayName: string | undefined,
284 pythonSysPrefix: string = '',
285 filesInCwd: Uri[] = []
286): KernelFailure | undefined {
287 // eslint-disable-next-line @typescript-eslint/no-explicit-any
288 const stdErrOrStackTrace = error instanceof BaseError ? error.stdErr || error.stack || '' : error.toString();
289 const lastTwolinesOfError = getLastTwoLinesFromPythonTracebackWithErrorMessage(stdErrOrStackTrace);
290 const stdErr = stdErrOrStackTrace.toLowerCase();
291 if (error instanceof SessionDisposedError) {
292 return {
293 reason: KernelFailureReason.sessionDisposed,
294 message: DataScience.sessionDisposed,
295 moreInfoLink: 'https://aka.ms/kernelDisposedCannotRunCell',
296 telemetrySafeTags: ['deadSession']
297 };
298 }
299 if (stdErr.includes("ImportError: No module named 'win32api'".toLowerCase())) {
300 // force re-installing ipykernel worked.
301 /*
302 File "C:\Users\<user>\miniconda3\envs\env_zipline\lib\contextlib.py", line 59, in enter
303 return next(self.gen)
304 File "C:\Users\<user>\miniconda3\envs\env_zipline\lib\site-packages\jupyter_client\connect.py", line 100, in secure_write
305 win32_restrict_file_to_user(fname)
306 File "C:\Users\<user>\miniconda3\envs\env_zipline\lib\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
307 import win32api
308 ImportError: No module named 'win32api'
309 */
310 return {
311 reason: KernelFailureReason.importWin32apiFailure,
312 message: DataScience.failedToStartKernelDueToWin32APIFailure,
313 moreInfoLink: 'https://aka.ms/kernelFailuresWin32Api',
314 telemetrySafeTags: ['win32api']
315 };
316 }
317 if (stdErr.includes('ImportError: DLL load failed'.toLowerCase()) && stdErr.includes('win32api')) {
318 // Possibly a conda issue on windows
319 /*
320 win32_restrict_file_to_user
321 import win32api
322 ImportError: DLL load failed: 找不到指定的程序。
323 */
324 return {
325 reason: KernelFailureReason.importWin32apiFailure,
326 message: DataScience.failedToStartKernelDueToWin32APIFailure,
327 moreInfoLink: 'https://aka.ms/kernelFailuresWin32Api',
328 telemetrySafeTags: ['dll.load.failed', 'win32api']
329 };
330 }
331 if (stdErr.includes('ImportError: DLL load failed'.toLowerCase())) {
332 /*
333 import xyz
334 ImportError: DLL load failed: ....
335 */
336 const moduleName =
337 lastTwolinesOfError && lastTwolinesOfError[0].toLowerCase().startsWith('import')

Callers 4

handleKernelErrorFunction · 0.90
completedWithErrorsMethod · 0.90
getErrorTagsFunction · 0.90

Calls 10

splitLinesFunction · 0.90
filterMethod · 0.80
mapMethod · 0.80
toStringMethod · 0.65
pushMethod · 0.65
basenameMethod · 0.65
dirnameMethod · 0.65

Tested by

no test coverage detected