From 1e505001d4c515bdd13f8574cb22aa6194032f54 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 1 Oct 2026 22:53:04 +0000 Subject: [PATCH] fix(coding-conventions): Refactor relocation API call to use try/catch Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com> --- static/gsAdmin/views/relocationCreate.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/static/gsAdmin/views/relocationCreate.tsx b/static/gsAdmin/views/relocationCreate.tsx index 4921189efe30..12128a7fb0df 100644 --- a/static/gsAdmin/views/relocationCreate.tsx +++ b/static/gsAdmin/views/relocationCreate.tsx @@ -45,20 +45,18 @@ function RelocationForm() { // Verify that the promo code exists, has remaining claims, etc. const promoCode = formData.get('promo_code'); if (typeof promoCode === 'string' && promoCode) { - await promoCodeApi - .requestPromise(`/promocodes-external/${promoCode}`, { + try { + await promoCodeApi.requestPromise(`/promocodes-external/${promoCode}`, { method: 'GET', host: cell.locality_url, - }) - .catch(error => { - if (error instanceof RequestError && error.status === 403) { - addErrorMessage(PROMO_CODE_ERROR_MSG); - - // Ensure that the wrapping `catch` block doesn't try to re-print this error message. - // eslint-disable-next-line unicorn/error-message - throw new Error(); - } }); + } catch (error) { + if (error instanceof RequestError && error.status === 403) { + addErrorMessage(PROMO_CODE_ERROR_MSG); + return; + } + throw error; + } } // Start the relocation.