Skip to content

Commit

Permalink
fix: prevent crash if there is error when executing
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhas committed Oct 17, 2018
1 parent ba73b69 commit d578fd0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/ts/executors/custom-command-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Executor } from "./executor";
import { CommandLineExecutionArgumentValidator } from "../execution-argument-validators/command-line-execution-argument-validator";
import { UeliHelpers } from "../helpers/ueli-helpers";
import { exec } from "child_process";
import { dialog } from "electron";

export class CustomCommandExecutor implements Executor {
public hideAfterExecution = true;
Expand All @@ -25,7 +26,7 @@ export class CustomCommandExecutor implements Executor {
this.hideAfterExecution = true;
exec(executionArgument, (err: Error): void => {
if (err) {
throw err;
dialog.showErrorBox("Execute file/folde path", err.stack || err.message);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/executors/file-path-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class FilePathExecutor implements Executor {
private handleAlternativeExecuteDir(filePath: string) {
childProcess.exec(`"${this.textEditorPath}" "${filePath}"`, (err) => {
if (err) {
throw err;
dialog.showErrorBox("Execute file/folde path", err.stack || err.message);
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/ts/executors/web-search-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Executor } from "./executor";
import { platform } from "os";
import { WebSearchHelpers } from "../helpers/web-search-helper";
import { WebSearch } from "../web-search";
import { dialog } from "electron";

export class WebSearchExecutor implements Executor {
public readonly hideAfterExecution = true;
Expand All @@ -22,7 +23,7 @@ export class WebSearchExecutor implements Executor {
const command = Injector.getOpenUrlWithDefaultBrowserCommand(platform(), executionArgument);
exec(command, (err) => {
if (err) {
throw err;
dialog.showErrorBox("Execute file/folde path", err.stack || err.message);
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/ts/executors/web-url-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Executor } from "./executor";
import { Injector } from "../injector";
import { exec } from "child_process";
import { platform } from "os";
import { dialog } from "electron";

export class WebUrlExecutor implements Executor {
public readonly hideAfterExecution = true;
Expand All @@ -16,7 +17,7 @@ export class WebUrlExecutor implements Executor {
private handleCommandExecution(command: string): void {
exec(command, (err) => {
if (err) {
throw err;
dialog.showErrorBox("Execute file/folde path", err.stack || err.message);
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/ts/executors/windows-settings-executor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { exec } from "child_process";
import { Executor } from "./executor";
import { WindowsSettingsHelpers } from "../helpers/windows-settings-helpers";
import { dialog } from "electron";

export class WindowsSettingsExecutor implements Executor {
public readonly hideAfterExecution = true;
Expand All @@ -12,7 +13,7 @@ export class WindowsSettingsExecutor implements Executor {

exec(`start ${command}`, (err): void => {
if (err) {
throw err;
dialog.showErrorBox("Execute file/folde path", err.stack || err.message);
}
});
}
Expand Down

0 comments on commit d578fd0

Please sign in to comment.