Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions static/gsAdmin/views/relocationCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading