Add guard clause for errors on ImportExportModal
This commit is contained in:
parent
d2f9684574
commit
d2ea5efa43
@ -103,6 +103,7 @@ function ImportExportModal({
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
backgroundTaskRunningRef.current = false;
|
backgroundTaskRunningRef.current = false;
|
||||||
|
if (e instanceof(Error)) {
|
||||||
if (e.message.startsWith("Max buffer length exceeded")) {
|
if (e.message.startsWith("Max buffer length exceeded")) {
|
||||||
setError(
|
setError(
|
||||||
new Error(
|
new Error(
|
||||||
@ -114,6 +115,7 @@ function ImportExportModal({
|
|||||||
setError(e);
|
setError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Set file input to null to allow adding the same data 2 times in a row
|
// Set file input to null to allow adding the same data 2 times in a row
|
||||||
if (fileInputRef.current) {
|
if (fileInputRef.current) {
|
||||||
fileInputRef.current.value = "";
|
fileInputRef.current.value = "";
|
||||||
@ -393,10 +395,12 @@ function ImportExportModal({
|
|||||||
const blob = new Blob([buffer]);
|
const blob = new Blob([buffer]);
|
||||||
saveAs(blob, `${shortid.generate()}.owlbear`);
|
saveAs(blob, `${shortid.generate()}.owlbear`);
|
||||||
addSuccessToast("Exported", checkedMaps, checkedTokens);
|
addSuccessToast("Exported", checkedMaps, checkedTokens);
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
|
if (e instanceof(Error)) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
setError(e);
|
setError(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
backgroundTaskRunningRef.current = false;
|
backgroundTaskRunningRef.current = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user