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

Function handleKernelError

src/kernels/errors/kernelErrorHandler.ts:320–514  ·  view source on GitHub ↗
(
        err: Error,
        errorContext: KernelAction,
        kernelConnection: KernelConnectionMetadata,
        resource: Resource,
        actionSource: KernelActionSource
    )

Source from the content-addressed store, hash-verified

318 }
319 }
320 public async handleKernelError(
321 err: Error,
322 errorContext: KernelAction,
323 kernelConnection: KernelConnectionMetadata,
324 resource: Resource,
325 actionSource: KernelActionSource
326 ): Promise<KernelInterpreterDependencyResponse> {
327 if (!isCancellationError(err)) {
328 logger.warn(`Kernel Error, context = ${errorContext}`, err);
329 }
330 err = WrappedError.unwrap(err);
331
332 // Jupyter kernels, non zmq actually do the dependency install themselves
333 if (isCancellationError(err)) {
334 this.sendKernelTelemetry(err, errorContext, resource, 'cancelled');
335 return KernelInterpreterDependencyResponse.cancel;
336 } else if (err instanceof JupyterKernelDependencyError) {
337 logger.warn(`Jupyter Kernel Dependency Error, reason=${err.reason}`, err);
338 this.sendKernelTelemetry(err, errorContext, resource, err.category);
339 if (err.reason === KernelInterpreterDependencyResponse.uiHidden && this.kernelDependency) {
340 // At this point we're handling the error, and if the error was initially swallowed due to
341 // auto start (ui hidden), now we need to display the error to the user.
342 const tokenSource = new CancellationTokenSource();
343 try {
344 const cannotChangeKernels = actionSource === '3rdPartyExtension';
345 return this.kernelDependency.installMissingDependencies({
346 resource,
347 kernelConnection,
348 ui: new DisplayOptions(false),
349 token: tokenSource.token,
350 ignoreCache: true,
351 cannotChangeKernels
352 });
353 } finally {
354 tokenSource.dispose();
355 }
356 } else {
357 return err.reason;
358 }
359 // Use the kernel dependency service to first determine if this is because dependencies are missing or not
360 } else if ((errorContext === 'start' || errorContext === 'restart') && err instanceof JupyterInstallError) {
361 this.sendKernelTelemetry(err, errorContext, resource, err.category);
362 const response = this.dependencyManager
363 ? await this.dependencyManager.installMissingDependencies(err)
364 : JupyterInterpreterDependencyResponse.cancel;
365 return response === JupyterInterpreterDependencyResponse.ok
366 ? KernelInterpreterDependencyResponse.ok
367 : KernelInterpreterDependencyResponse.cancel;
368 } else if (
369 err instanceof RemoteJupyterServerConnectionError ||
370 err instanceof RemoteJupyterServerUriProviderError ||
371 err instanceof InvalidRemoteJupyterServerUriHandleError
372 ) {
373 this.sendKernelTelemetry(err, errorContext, resource, err.category);
374 const message =
375 err instanceof InvalidRemoteJupyterServerUriHandleError
376 ? ''
377 : err instanceof RemoteJupyterServerConnectionError

Callers

nothing calls this directly

Calls 15

disposeMethod · 0.95
isCancellationErrorFunction · 0.90
getJupyterDisplayNameFunction · 0.90
sendTelemetryEventFunction · 0.90
getPythonEnvDisplayNameFunction · 0.90
getPythonEnvironmentNameFunction · 0.90
getDisplayPathFunction · 0.90
getSysPrefixFunction · 0.90
analyzeKernelErrorsFunction · 0.90
unwrapMethod · 0.80

Tested by

no test coverage detected