From b4fd955c788815d3d23be38a318c92c32572e655 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Fri, 7 Jan 2022 20:37:07 +0000 Subject: [PATCH] catch icon generation errors and log to console (#441) --- frontend/src/components/PolkadotIcon.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/PolkadotIcon.tsx b/frontend/src/components/PolkadotIcon.tsx index 8dab9b8..16b6822 100644 --- a/frontend/src/components/PolkadotIcon.tsx +++ b/frontend/src/components/PolkadotIcon.tsx @@ -174,7 +174,14 @@ function getColors(address: string): string[] { * @description Generate a array of the circles that make up an indenticon */ function generate(address: string, isSixPoint = false): Circle[] { - const colors = getColors(address); + let colors: string[] = []; + try { + colors = getColors(address); + } catch (e) { + console.error( + `Error decoding address to generate validator icon for: ${address} (${e})` + ); + } return [OUTER_CIRCLE].concat( getCircleXY(isSixPoint).map( @@ -183,7 +190,7 @@ function generate(address: string, isSixPoint = false): Circle[] { cx, cy, r: Z, - fill: colors[index], + fill: colors[index] || 'rgb(255,255,255)', }; } )