Skip to content

Commit c946d41

Browse files
committed
error
1 parent 71e550b commit c946d41

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/browser.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@ export async function ensureBrowserConnected(options: {
8181
}
8282

8383
logger('Connecting Puppeteer to ', JSON.stringify(connectOptions));
84-
browser = await puppeteer.connect(connectOptions);
84+
try {
85+
browser = await puppeteer.connect(connectOptions);
86+
} catch (err) {
87+
throw new Error(
88+
'Could not connect to Chrome. Check if Chrome is running and remote debugging is enabled.',
89+
{
90+
cause: err,
91+
},
92+
);
93+
}
8594
logger('Connected Puppeteer');
8695
return browser;
8796
}

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ export function parseArguments(version: string, argv = process.argv) {
236236
],
237237
[
238238
'$0 --auto-connect',
239-
'Connect to a stable Chrome instance running instead of launching a new instance',
239+
'Connect to a stable Chrome instance (Chrome 145+) running instead of launching a new instance',
240240
],
241241
[
242242
'$0 --auto-connect --channel=canary',
243-
'Connect to a canary Chrome instance running instead of launching a new instance',
243+
'Connect to a canary Chrome instance (Chrome 145+) running instead of launching a new instance',
244244
],
245245
]);
246246

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ function registerTool(tool: ToolDefinition): void {
142142
};
143143
} catch (err) {
144144
logger(`${tool.name} error:`, err, err?.stack);
145-
const errorText = err && 'message' in err ? err.message : String(err);
145+
let errorText = err && 'message' in err ? err.message : String(err);
146+
if ('cause' in err && err.cause) {
147+
errorText += `\nCause: ${err.cause.message}`;
148+
}
146149
return {
147150
content: [
148151
{

0 commit comments

Comments
 (0)