mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
Add new errorCode property to notebook errors to see if starting a notebook session failed. (#18617)
This commit is contained in:
@@ -108,7 +108,7 @@ export class ExtHostNotebook implements ExtHostNotebookShape {
|
||||
};
|
||||
return details;
|
||||
} catch (error) {
|
||||
throw typeof (error) === 'string' ? new Error(error) : error;
|
||||
throw typeof (error) === 'string' ? new Error(error) : Object.assign(error, { errorCode: error.response?.status }); // Add errorCode so that status info persists over RPC
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ export class ClientSession implements IClientSession {
|
||||
private _kernelConfigActions: ((kernelName: string) => Promise<any>)[] = [];
|
||||
private _connectionId: string = '';
|
||||
|
||||
private readonly _kernelNotFoundError = 501;
|
||||
|
||||
constructor(private options: IClientSessionOptions) {
|
||||
this._notebookUri = options.notebookUri;
|
||||
this._executeManager = options.executeManager;
|
||||
@@ -62,7 +64,6 @@ export class ClientSession implements IClientSession {
|
||||
public async initialize(): Promise<void> {
|
||||
try {
|
||||
this._serverLoadFinished = this.startServer(this.options.kernelSpec);
|
||||
await this._serverLoadFinished;
|
||||
await this.initializeSession();
|
||||
await this.updateCachedKernelSpec();
|
||||
} catch (err) {
|
||||
@@ -116,8 +117,8 @@ export class ClientSession implements IClientSession {
|
||||
session.defaultKernelLoaded = true;
|
||||
} catch (err) {
|
||||
// TODO move registration
|
||||
if (err && err.response && err.response.status === 501) {
|
||||
this.options.notificationService.warn(localize('kernelRequiresConnection', "Kernel {0} was not found. The default kernel will be used instead.", kernelSpec.name));
|
||||
if (err.response?.status === this._kernelNotFoundError || err.errorCode === this._kernelNotFoundError) {
|
||||
this.options.notificationService.warn(localize('kernelRequiresConnection', "Kernel '{0}' was not found. The default kernel will be used instead.", kernelSpec.name));
|
||||
session = await this._executeManager.sessionManager.startNew({
|
||||
path: this.notebookUri.fsPath,
|
||||
kernelName: undefined
|
||||
|
||||
Reference in New Issue
Block a user