Skip to content

Commit

Permalink
Merge pull request #20 from kaishuu0123/fix/error-handling
Browse files Browse the repository at this point in the history
fix error handling and view error message.
  • Loading branch information
kaishuu0123 authored Jan 15, 2019
2 parents 0d1d3c1 + 28998b7 commit 124d4fd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-erd-preview",
"displayName": "ERD Preview",
"description": "An extension for Visual Studio Code to preview erd(.er) files",
"version": "3.1.0",
"version": "4.0.1",
"publisher": "kaishuu0123",
"engines": {
"vscode": "^1.25.0"
Expand Down
11 changes: 10 additions & 1 deletion src/commands/savePdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export class SavePdfCommand extends SaveCommand implements Command {
return;
}

const activeTextEditor = vscode.window.activeTextEditor;
if (resource && resource.scheme !== 'file') {
vscode
.window
.showErrorMessage('Please save to file before PDF export.');

return;
}

vscode.window
.showSaveDialog({
Expand All @@ -25,6 +31,9 @@ export class SavePdfCommand extends SaveCommand implements Command {
if (uri) {
writeToFile(resource, uri.fsPath, 'pdf');
}
})
.then(undefined, err => {
console.log(err);
});
}
}
11 changes: 11 additions & 0 deletions src/commands/savePng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export class SavePngCommand extends SaveCommand implements Command {
return;
}

if (resource && resource.scheme !== 'file') {
vscode
.window
.showErrorMessage('Please save to file before PNG export.');

return;
}

vscode.window
.showSaveDialog({
defaultUri: resource,
Expand All @@ -23,6 +31,9 @@ export class SavePngCommand extends SaveCommand implements Command {
if (uri) {
writeToFile(resource, uri.fsPath, 'png');
}
})
.then(undefined, err => {
console.log(err);
});
}
}
11 changes: 10 additions & 1 deletion src/commands/saveSvg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export class SaveSvgCommand extends SaveCommand implements Command {
return;
}

const activeTextEditor = vscode.window.activeTextEditor;
if (resource && resource.scheme !== 'file') {
vscode
.window
.showErrorMessage('Please save to file before SVG export.');

return;
}

vscode.window
.showSaveDialog({
Expand All @@ -25,6 +31,9 @@ export class SaveSvgCommand extends SaveCommand implements Command {
if (uri) {
writeToFile(resource, uri.fsPath, 'svg');
}
})
.then(undefined, err => {
console.log(err);
});
}
}

0 comments on commit 124d4fd

Please sign in to comment.