chore: beautify error message (#18002)
This commit is contained in:
Родитель
8ff2eda16a
Коммит
64e80f0460
|
@ -81,10 +81,12 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
|||
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
|
||||
env: options.env ? envObjectToArray(options.env) : undefined,
|
||||
};
|
||||
const browser = Browser.from((await this._channel.launch(launchOptions)).browser);
|
||||
browser._logger = logger;
|
||||
browser._setBrowserType(this);
|
||||
return browser;
|
||||
return await this._wrapApiCall(async () => {
|
||||
const browser = Browser.from((await this._channel.launch(launchOptions)).browser);
|
||||
browser._logger = logger;
|
||||
browser._setBrowserType(this);
|
||||
return browser;
|
||||
});
|
||||
}
|
||||
|
||||
private async _connectInsteadOfLaunching(): Promise<Browser> {
|
||||
|
@ -119,13 +121,15 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
|||
channel: options.channel,
|
||||
userDataDir,
|
||||
};
|
||||
const result = await this._channel.launchPersistentContext(persistentParams);
|
||||
const context = BrowserContext.from(result.context);
|
||||
context._options = contextParams;
|
||||
context._logger = logger;
|
||||
context._setBrowserType(this);
|
||||
await this._onDidCreateContext?.(context);
|
||||
return context;
|
||||
return await this._wrapApiCall(async () => {
|
||||
const result = await this._channel.launchPersistentContext(persistentParams);
|
||||
const context = BrowserContext.from(result.context);
|
||||
context._options = contextParams;
|
||||
context._logger = logger;
|
||||
context._setBrowserType(this);
|
||||
await this._onDidCreateContext?.(context);
|
||||
return context;
|
||||
});
|
||||
}
|
||||
|
||||
connect(options: api.ConnectOptions & { wsEndpoint?: string }): Promise<api.Browser>;
|
||||
|
|
|
@ -132,8 +132,13 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
|||
return result;
|
||||
} catch (e) {
|
||||
const innerError = ((process.env.PWDEBUGIMPL || isUnderTest()) && e.stack) ? '\n<inner error>\n' + e.stack : '';
|
||||
e.message = apiName + ': ' + e.message;
|
||||
e.stack = e.message + '\n' + frameTexts.join('\n') + innerError;
|
||||
if (apiName && !apiName.includes('<anonymous>'))
|
||||
e.message = apiName + ': ' + e.message;
|
||||
const stackFrames = '\n' + frameTexts.join('\n') + innerError;
|
||||
if (stackFrames.trim())
|
||||
e.stack = e.message + stackFrames;
|
||||
else
|
||||
e.stack = '';
|
||||
csi?.onApiCallEnd(callCookie, e);
|
||||
logApiCall(logger, `<= ${apiName} failed`, isInternal);
|
||||
throw e;
|
||||
|
|
Загрузка…
Ссылка в новой задаче