Add guard clause for errors on ImportExportModal
This commit is contained in:
parent
d2f9684574
commit
d2ea5efa43
@ -103,15 +103,17 @@ function ImportExportModal({
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
backgroundTaskRunningRef.current = false;
|
backgroundTaskRunningRef.current = false;
|
||||||
if (e.message.startsWith("Max buffer length exceeded")) {
|
if (e instanceof(Error)) {
|
||||||
setError(
|
if (e.message.startsWith("Max buffer length exceeded")) {
|
||||||
new Error(
|
setError(
|
||||||
"Max image size exceeded ensure your database doesn't have an image over 100MB"
|
new Error(
|
||||||
)
|
"Max image size exceeded ensure your database doesn't have an image over 100MB"
|
||||||
);
|
)
|
||||||
} else {
|
);
|
||||||
console.error(e);
|
} else {
|
||||||
setError(e);
|
console.error(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
|
||||||
@ -393,9 +395,11 @@ 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) {
|
||||||
console.error(e);
|
if (e instanceof(Error)) {
|
||||||
setError(e);
|
console.error(e);
|
||||||
|
setError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
backgroundTaskRunningRef.current = false;
|
backgroundTaskRunningRef.current = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user