Browse Source

feat(nc-gui): error handling for import

pull/4135/head
Wing-Kam Wong 2 years ago
parent
commit
2ec7d24ac2
  1. 5
      packages/nc-gui/components/dlg/QuickImport.vue
  2. 12
      packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts

5
packages/nc-gui/components/dlg/QuickImport.vue

@ -210,10 +210,11 @@ async function parseAndExtractData(val: UploadFile[] | ArrayBuffer | string) {
} }
importData.value = templateGenerator!.getData() importData.value = templateGenerator!.getData()
templateEditorModal.value = true templateEditorModal.value = true
isParsingData.value = false
preImportLoading.value = false
} catch (e: any) { } catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} finally {
isParsingData.value = false
preImportLoading.value = false
} }
} }

12
packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts

@ -200,7 +200,7 @@ export default class CSVTemplateAdapter {
} }
async _parseTableData(tableIdx: number, source: UploadFile | string, tn: string) { async _parseTableData(tableIdx: number, source: UploadFile | string, tn: string) {
return new Promise((resolve) => { return new Promise((resolve, reject) => {
const that = this const that = this
let steppers = 0 let steppers = 0
if (that.config.shouldImportData) { if (that.config.shouldImportData) {
@ -235,8 +235,8 @@ export default class CSVTemplateAdapter {
console.log(`getData(): steppers: ${steppers}`) console.log(`getData(): steppers: ${steppers}`)
resolve(true) resolve(true)
}, },
error(error: Error) { error(e: Error) {
message.error(error.message) reject(e)
}, },
}) })
} }
@ -244,7 +244,7 @@ export default class CSVTemplateAdapter {
} }
async _parseTableMeta(tableIdx: number, source: UploadFile | string) { async _parseTableMeta(tableIdx: number, source: UploadFile | string) {
return new Promise((resolve) => { return new Promise((resolve, reject) => {
const that = this const that = this
let steppers = 0 let steppers = 0
const tn = ((this.config.importFromURL ? (source as string).split('/').pop() : (source as UploadFile).name) as string) const tn = ((this.config.importFromURL ? (source as string).split('/').pop() : (source as UploadFile).name) as string)
@ -291,8 +291,8 @@ export default class CSVTemplateAdapter {
await that._parseTableData(tableIdx, source, tn) await that._parseTableData(tableIdx, source, tn)
resolve(true) resolve(true)
}, },
error(error: Error) { error(e: Error) {
message.error(error.message) reject(e)
}, },
}) })
}) })

Loading…
Cancel
Save