From 884eeb65aa1ea2d198d541bd2dc715fa86cc9e48 Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Mon, 8 Jan 2024 10:57:43 +0000 Subject: [PATCH] refactor: add descriptive error on data extract failure --- .../components/createnewproject/DataExtract.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/createnewproject/DataExtract.tsx b/src/frontend/src/components/createnewproject/DataExtract.tsx index 161e4aac08..c9abbbe83f 100644 --- a/src/frontend/src/components/createnewproject/DataExtract.tsx +++ b/src/frontend/src/components/createnewproject/DataExtract.tsx @@ -69,8 +69,18 @@ const DataExtract = ({ flag, customLineUpload, setCustomLineUpload, customPolygo const geojsonExtract = await fgbGeojson.deserialize(uint8ArrayData); dispatch(CreateProjectActions.setDataExtractGeojson(geojsonExtract)); } catch (error) { - // TODO add error message for user - console.error('Error getting data extract:', error); + let errorMsg = JSON.stringify(error?.response?.data?.detail[0]?.msg); + if (errorMsg && errorMsg.includes('higher than Threshold')) { + errorMsg = 'Project area too large for data extract generation. Please reduce size or use custom extract.'; + } + dispatch( + CommonActions.SetSnackBar({ + open: true, + message: errorMsg || 'Error getting data extract.', + variant: 'error', + duration: 10000, + }), + ); } } };