(core) Show proper message on empty Excel import, rather than a code error

Summary:
- Previously showed "UnboundLocalError". Now will show:
    Import failed: Failed to parse Excel file.
    Error: No tables found (1 empty tables skipped)
- Also fix logging for import code

Test Plan: Added a test case

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3396
This commit is contained in:
Dmitry S
2022-04-26 01:50:57 -04:00
parent dcafa96b5b
commit e59dcc142d
4 changed files with 14 additions and 3 deletions

View File

@@ -111,6 +111,7 @@ const cssModalBody = styled('div', `
padding: 16px 0;
overflow-y: auto;
max-width: 470px;
white-space: pre-line;
`);
const cssModalHeader = styled('div', `

View File

@@ -141,7 +141,7 @@ export class DocPluginManager {
'.csv' : 'CSV',
};
const fileType = extToType[path.extname(fileName)] || path.extname(fileName);
throw new Error(`Failed to parse ${fileType} file. Error: ${messages.join("; ")}`);
throw new Error(`Failed to parse ${fileType} file.\nError: ${messages.join("; ")}`);
}
throw new Error(`File format is not supported.`);
}