mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 04:13:47 +00:00
Catch xlsx error (#1487)
* catch potential xlsx errors * clear worksheet errors when starting new connections
This commit is contained in:
committed by
GitHub
parent
bac11adeb1
commit
0b36608134
@@ -76,6 +76,7 @@ export default function GSheetSetup(props: GSheetSetupProps) {
|
||||
const handleConnect = async () => {
|
||||
if (!file) return;
|
||||
if (!sheetId) return;
|
||||
patchStepData({ worksheet: { available: false, error: '' } });
|
||||
|
||||
setLoading('connect');
|
||||
const result = await connect(file, sheetId);
|
||||
|
||||
@@ -208,6 +208,17 @@ async function verifySheet(
|
||||
});
|
||||
return { worksheetOptions: spreadsheets.data.sheets.map((i) => i.properties.title) };
|
||||
} catch (error) {
|
||||
// attempt to catch errors caused by importing xlsx
|
||||
if (
|
||||
error.code === 400 &&
|
||||
Array.isArray(error.errors) &&
|
||||
error.errors[0].reason === 'failedPrecondition' &&
|
||||
error.errors[0].message === 'This operation is not supported for this document'
|
||||
) {
|
||||
throw new Error(
|
||||
'This operation is not supported for this document. the reason is most likely that this is a .xlsx document',
|
||||
);
|
||||
}
|
||||
const errorMessage = getErrorMessage(error);
|
||||
throw new Error(`Failed to verify sheet: ${errorMessage}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user