Skip to content

Commit

Permalink
refactor: add descriptive error on data extract failure
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jan 8, 2024
1 parent 67e7dc3 commit 884eeb6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/frontend/src/components/createnewproject/DataExtract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
);
}
}
};
Expand Down

0 comments on commit 884eeb6

Please sign in to comment.