mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
Handle invalid file on import (#7960)
* handle invalid file on import * update * error msg update * Update frontend/src/HomePage/HomePage.jsx Co-authored-by: Midhun G S <gsmithun4@gmail.com> --------- Co-authored-by: Midhun G S <gsmithun4@gmail.com>
This commit is contained in:
parent
56085460c4
commit
4b2f9af794
1 changed files with 9 additions and 2 deletions
|
|
@ -209,11 +209,18 @@ class HomePageComponent extends React.Component {
|
|||
fileReader.readAsText(file, 'UTF-8');
|
||||
fileReader.onload = (event) => {
|
||||
const result = event.target.result;
|
||||
const fileContent = JSON.parse(result);
|
||||
let fileContent;
|
||||
try {
|
||||
fileContent = JSON.parse(result);
|
||||
} catch (parseError) {
|
||||
toast.error(`Could not import: ${parseError}`);
|
||||
return;
|
||||
}
|
||||
this.setState({ fileContent, fileName, showImportAppModal: true });
|
||||
};
|
||||
fileReader.onerror = (error) => {
|
||||
throw new Error(`Could not import the app: ${error}`);
|
||||
toast.error(`Could not import the app: ${error}`);
|
||||
return;
|
||||
};
|
||||
event.target.value = null;
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue