Skip to content

Commit

Permalink
Properly handle unknown errors when creating color scales
Browse files Browse the repository at this point in the history
Previously, there was no guarantee that an unknown error would produce a
helpful message.
  • Loading branch information
victorlin committed Nov 12, 2024
1 parent aa30581 commit 6083f73
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util/colorScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export const calcColorScale = (
};
} catch (err) {
/* Catch all errors to avoid app crashes */
console.error("Error creating color scales. Details:\n", err.message);
const errorMessage = err instanceof Error ? err.message : String(err);
console.error("Error creating color scales. Details:\n", errorMessage);
return {
scale: () => unknownColor,
continuous: false,
Expand Down

0 comments on commit 6083f73

Please sign in to comment.