Skip to content

Commit

Permalink
Add treatment of error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreKavalerski committed Jul 7, 2020
1 parent 799ec6d commit 0576932
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ function getSolution() {
const aStar = AStarPuzzleSolver;
const state = getActualState();
console.log(state);
const solution = aStar.solvePuzzle(state);
showResults(solution);
viewSolution(solution);
try {
const solution = aStar.solvePuzzle(state);
showResults(solution);
viewSolution(solution);
} catch (err) {
alert(
"O estado inicial é solucionável! Por favor, gere outro estado e tente novamente."
);
}
}

function showResults(solution) {
Expand Down

0 comments on commit 0576932

Please sign in to comment.