From b82fd9a5c503439fd61bacf82c408da46aff1035 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 6 Mar 2023 20:40:16 +0100 Subject: [PATCH] feat(cli): improve error message on script timeout --- packages/cli/src/bin/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/bin/index.ts b/packages/cli/src/bin/index.ts index 856d269a..197404b5 100644 --- a/packages/cli/src/bin/index.ts +++ b/packages/cli/src/bin/index.ts @@ -15,6 +15,7 @@ import { import axeTestUrls from '../lib/axe-test-urls'; import event from '../lib/events'; import { startDriver } from '../lib/webdriver'; +import { error as selenium_error } from 'selenium-webdriver'; const cli = async ( args: OptionValues, @@ -106,8 +107,19 @@ const cli = async ( rules, disable }; + let outcome; try { - const outcome = await axeTestUrls(urls, testPageConfigParams, events); + try { + outcome = await axeTestUrls(urls, testPageConfigParams, events); + } catch (e) { + if (e instanceof selenium_error.ScriptTimeoutError) { + console.error(error('Error: %s'), e.message); + console.log(`The timeout is currently configured to be ${timeout} seconds (you can change it with --timeout).`) + process.exit(2); + } else { + throw e; + } + } if (silentMode) { process.stdout.write(JSON.stringify(outcome, null, 2)); return;