mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 01:25:38 -05:00
handle import errors (#8905)
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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[]) {
|
||||
|
||||
Reference in New Issue
Block a user