UI: Catch TypeError when uploading a config file and set appropriate error message
This error message is different from the one in sendConfigToServer() since this one only checks for 3 things (metadata.encrypted, configuration, credentials). The one in sendConfigToServer() tries importing the whole configuration.
This commit is contained in:
parent
b4c9f0df9e
commit
3d00460f98
|
@ -142,9 +142,20 @@ const ConfigImportModal = (props: Props) => {
|
|||
setErrorMessage('File is not in a valid json format');
|
||||
return
|
||||
}
|
||||
setConfigEncrypted(importContents['metadata']['encrypted']);
|
||||
setConfigContents(importContents['configuration']);
|
||||
setConfigCredentials(importContents['credentials']);
|
||||
|
||||
try {
|
||||
setConfigEncrypted(importContents['metadata']['encrypted']);
|
||||
setConfigContents(importContents['configuration']);
|
||||
setConfigCredentials(importContents['credentials']);
|
||||
} catch (e) {
|
||||
if (e instanceof TypeError) {
|
||||
setErrorMessage('Missing required fields, configuration file is most '
|
||||
+ 'likely from an old version')
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
reader.readAsText(event.target.files[0]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue