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", "name": "import",
"displayName": "SQL Server Import", "displayName": "SQL Server Import",
"description": "SQL Server Import for Azure Data Studio supports importing CSV or JSON files into SQL Server.", "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", "publisher": "Microsoft",
"preview": true, "preview": true,
"engines": { "engines": {

View File

@@ -71,7 +71,14 @@ export class ProsePreviewPage extends ImportPage {
async onPageEnter(): Promise<boolean> { async onPageEnter(): Promise<boolean> {
this.loading.loading = true; 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; this.loading.loading = false;
if (proseResult) { if (proseResult) {
await this.populateTable(this.model.proseDataPreview, this.model.proseColumns.map(c => c.columnName)); 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([], []); await this.populateTable([], []);
this.isSuccess = false; this.isSuccess = false;
if (this.form) { if (this.form) {
this.resultTextComponent.value = this.failureTitle; this.resultTextComponent.value = this.failureTitle + '\n' + (error ?? '');
} }
return false; return false;
} }
@@ -113,20 +120,21 @@ export class ProsePreviewPage extends ImportPage {
} }
private async handleProse(): Promise<boolean> { private async handleProse(): Promise<boolean> {
return this.provider.sendPROSEDiscoveryRequest({ const response = await this.provider.sendPROSEDiscoveryRequest({
filePath: this.model.filePath, filePath: this.model.filePath,
tableName: this.model.table, tableName: this.model.table,
schemaName: this.model.schema, schemaName: this.model.schema,
fileType: this.model.fileType fileType: this.model.fileType
}).then((result) => { });
if (result) {
this.model.proseDataPreview = null; this.model.proseDataPreview = null;
if (result.dataPreview) { if (response.dataPreview) {
this.model.proseDataPreview = result.dataPreview; this.model.proseDataPreview = response.dataPreview;
} }
this.model.proseColumns = []; this.model.proseColumns = [];
if (result.columnInfo) { if (response.columnInfo) {
result.columnInfo.forEach((column) => { response.columnInfo.forEach((column) => {
this.model.proseColumns.push({ this.model.proseColumns.push({
columnName: column.name, columnName: column.name,
dataType: column.sqlType, dataType: column.sqlType,
@@ -136,9 +144,8 @@ export class ProsePreviewPage extends ImportPage {
}); });
return true; return true;
} }
}
return false; return false;
});
} }
private async populateTable(tableData: string[][], columnHeaders: string[]) { private async populateTable(tableData: string[][], columnHeaders: string[]) {