From 91c2f20580bcceb453f83897daea7ad8a1d7873c Mon Sep 17 00:00:00 2001 From: dnlbui Date: Thu, 26 Sep 2024 11:25:07 -0500 Subject: [PATCH] update error status and update error string --- api/handlers/node.ts | 8 +++----- hooks/fetcher.ts | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/api/handlers/node.ts b/api/handlers/node.ts index f149071..eaa0986 100644 --- a/api/handlers/node.ts +++ b/api/handlers/node.ts @@ -131,16 +131,14 @@ export default function configureNodeHandlers(apiRouter: Router) { console.log('Executing operator-cli stake_info...'); - const output = execFileSync('operator-cli', ['stake_info', address], { encoding: 'utf8' }); + const output = execFileSync('operator-cli', ['stake_info', address], { encoding: 'utf8' }) // Check for specific error message // Case where query was valid but no stake info was found - if (output.includes('Error: No stake information found')) { - console.log('Entered error handling'); + if (output === 'No stake information found. Please fund the account and try again.') { // Check if the response headers have already been sent if (!res.headersSent) { - console.log('Sending 500 response: Account not found'); - res.status(500).json({ errorMessage: 'Account not found. Please ensure the account has been created and funded.', errorDetails: '' }); + res.status(404).json({ errorMessage: 'Account not found. Please ensure the account has been funded.', errorDetails: '' }); } return; } diff --git a/hooks/fetcher.ts b/hooks/fetcher.ts index 56a4ed4..e38b464 100644 --- a/hooks/fetcher.ts +++ b/hooks/fetcher.ts @@ -35,7 +35,7 @@ export const fetcher = async (input: RequestInfo | URL, const data = await res.json(); if (res.status === 403) { authService.logout(apiBase); - } else if (input.toString().includes('account') && res.status === 500 && data.errorMessage === `Account not found. Please ensure the account has been created and funded.`) { + } else if (input.toString().includes('account') && res.status === 404 && data.errorMessage === `Account not found. Please ensure the account has been funded.`) { throw new Error('No stake information found. Please fund the account and try again.'); } else if (res.status === 500) { showErrorMessage('Sorry, something went wrong. Please report this issue to our support team so we can investigate and resolve the problem.');