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