Skip to content

Commit

Permalink
updates error handling for failed bear-exec commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sloansparger committed Jun 7, 2020
1 parent 73f0ac4 commit a19a76f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/utils/bear-exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ export function bearExec<T>(action: string, rawParams: object): Promise<T> {
.catch(error => {
if (timeoutId) clearTimeout(timeoutId);
const [, ...errLines] = error.message.split("\n");
const parsedError = JSON.parse(errLines.join("\n"));
if (DEBUG === "true") {
console.log("raw error:", error);
console.log("err obj?:", errLines);
}

let parsedError;
try {
parsedError = JSON.parse(errLines.join("\n"));
} catch (err) {
return reject(
new CLIError("Unexpected response received from Bear.")
);
}

if (parsedError.errorMessage) {
reject(new CLIError(parsedError.errorMessage));
} else {
Expand Down

0 comments on commit a19a76f

Please sign in to comment.