handle import errors (#8905)

This commit is contained in:
Amir Omidi
2020-01-28 12:42:14 -08:00
committed by GitHub
parent 0c1edc1aeb
commit 7ef3f003dd
2 changed files with 31 additions and 24 deletions

View File

@@ -2,7 +2,7 @@
"name": "import",
"displayName": "SQL Server Import",
"description": "SQL Server Import for Azure Data Studio supports importing CSV or JSON files into SQL Server.",
"version": "0.13.0",
"version": "0.13.1",
"publisher": "Microsoft",
"preview": true,
"engines": {

View File

@@ -71,7 +71,14 @@ export class ProsePreviewPage extends ImportPage {
async onPageEnter(): Promise<boolean> {
this.loading.loading = true;
let proseResult = await this.handleProse();
let proseResult: boolean;
let error: string;
try {
proseResult = await this.handleProse();
} catch (ex) {
error = ex.toString();
}
this.loading.loading = false;
if (proseResult) {
await this.populateTable(this.model.proseDataPreview, this.model.proseColumns.map(c => c.columnName));
@@ -84,7 +91,7 @@ export class ProsePreviewPage extends ImportPage {
await this.populateTable([], []);
this.isSuccess = false;
if (this.form) {
this.resultTextComponent.value = this.failureTitle;
this.resultTextComponent.value = this.failureTitle + '\n' + (error ?? '');
}
return false;
}
@@ -113,32 +120,32 @@ export class ProsePreviewPage extends ImportPage {
}
private async handleProse(): Promise<boolean> {
return this.provider.sendPROSEDiscoveryRequest({
const response = await this.provider.sendPROSEDiscoveryRequest({
filePath: this.model.filePath,
tableName: this.model.table,
schemaName: this.model.schema,
fileType: this.model.fileType
}).then((result) => {
if (result) {
this.model.proseDataPreview = null;
if (result.dataPreview) {
this.model.proseDataPreview = result.dataPreview;
}
this.model.proseColumns = [];
if (result.columnInfo) {
result.columnInfo.forEach((column) => {
this.model.proseColumns.push({
columnName: column.name,
dataType: column.sqlType,
primaryKey: false,
nullable: column.isNullable
});
});
return true;
}
}
return false;
});
this.model.proseDataPreview = null;
if (response.dataPreview) {
this.model.proseDataPreview = response.dataPreview;
}
this.model.proseColumns = [];
if (response.columnInfo) {
response.columnInfo.forEach((column) => {
this.model.proseColumns.push({
columnName: column.name,
dataType: column.sqlType,
primaryKey: false,
nullable: column.isNullable
});
});
return true;
}
return false;
}
private async populateTable(tableData: string[][], columnHeaders: string[]) {