From 7422d22538c5ab57ae314dc0a38788517f7413e1 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 29 Jul 2023 11:40:03 +0100 Subject: [PATCH] Adds compatibility for skipped checks for server host reasons --- src/components/misc/ProgressBar.tsx | 11 +++++++++-- src/hooks/motherOfAllHooks.ts | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/components/misc/ProgressBar.tsx b/src/components/misc/ProgressBar.tsx index 1d2be06..90d1a9f 100644 --- a/src/components/misc/ProgressBar.tsx +++ b/src/components/misc/ProgressBar.tsx @@ -167,6 +167,9 @@ p { } pre { color: ${colors.danger}; + &.info { + color: ${colors.warning}; + } } `; @@ -202,7 +205,9 @@ const jobNames = [ 'sitemap', 'hsts', 'security-txt', + 'social-tags', 'linked-pages', + 'mail-server', // 'whois', 'features', 'carbon', @@ -360,7 +365,7 @@ const ProgressLoader = (props: { loadStatus: LoadingJob[], showModal: (err: Reac } }; - const showErrorModal = (name: string, state: LoadingState, timeTaken: number | undefined, error: string) => { + const showErrorModal = (name: string, state: LoadingState, timeTaken: number | undefined, error: string, isInfo?: boolean) => { const errorContent = ( Error Details for {name} @@ -368,7 +373,8 @@ const ProgressLoader = (props: { loadStatus: LoadingJob[], showModal: (err: Reac The {name} job failed with an {state} state after {timeTaken} ms. The server responded with the following error:

-
{error}
+ { /* If isInfo == true, then add .info className to pre */} +
{error}
); props.showModal(errorContent); @@ -409,6 +415,7 @@ const ProgressLoader = (props: { loadStatus: LoadingJob[], showModal: (err: Reac {(timeTaken && state !== 'loading') ? ` Took ${timeTaken} ms` : '' } { (retry && state !== 'success' && state !== 'loading') && ↻ Retry } { (error && state === 'error') && showErrorModal(name, state, timeTaken, error)}>■ Show Error } + { (error && state === 'skipped') && showErrorModal(name, state, timeTaken, error, true)}>■ Show Reason } ); }) diff --git a/src/hooks/motherOfAllHooks.ts b/src/hooks/motherOfAllHooks.ts index 8ff5ff0..fae8b16 100644 --- a/src/hooks/motherOfAllHooks.ts +++ b/src/hooks/motherOfAllHooks.ts @@ -38,21 +38,20 @@ const useMotherOfAllHooks = (params: UseIpAddressProps { return fetchRequest() .then((res: any) => { - if (!res) { + if (!res) { // No response :( + updateLoadingJobs(jobId, 'error', res.error || 'No response', reset); + } else if (res.error) { // Response returned an error message updateLoadingJobs(jobId, 'error', res.error, reset); - throw new Error('No response'); + } else if (res.skipped) { // Response returned a skipped message + updateLoadingJobs(jobId, 'skipped', res.skipped, reset); + } else { // Yay, everything went to plan :) + setResult(res); + updateLoadingJobs(jobId, 'success', '', undefined, res); } - if (res.error) { - updateLoadingJobs(jobId, 'error', res.error, reset); - throw new Error(res.error); - } - // All went to plan, set results and mark as done - setResult(res); - updateLoadingJobs(jobId, 'success', '', undefined, res); }) .catch((err) => { - // Something fucked up, log the error - updateLoadingJobs(jobId, 'error', err.error || err.message, reset); + // Something fucked up + updateLoadingJobs(jobId, 'error', err.error || err.message || 'Unknown error', reset); throw err; }) } @@ -69,6 +68,7 @@ const useMotherOfAllHooks = (params: UseIpAddressProps {});