File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @sovryn/utils ' : patch
3+ ---
4+
5+ fix: decimal util crashing when null value is given
Original file line number Diff line number Diff line change @@ -93,15 +93,29 @@ export class Decimal {
9393 case 'object' :
9494 if ( decimalish instanceof Decimal ) {
9595 return decimalish ;
96+ } else if ( decimalish === null || decimalish === undefined ) {
97+ return Decimal . ZERO ;
9698 } else {
97- throw new Error ( 'invalid Decimalish value' ) ;
99+ throw new Error (
100+ 'invalid Decimalish value: ' +
101+ typeof decimalish +
102+ '(' +
103+ decimalish +
104+ ')' ,
105+ ) ;
98106 }
99107 case 'string' :
100108 return Decimal . _fromString ( decimalish ) ;
101109 case 'number' :
102110 return Decimal . _fromString ( decimalish . toString ( ) ) ;
103111 default :
104- throw new Error ( 'invalid Decimalish value' ) ;
112+ throw new Error (
113+ 'invalid Decimalish value: ' +
114+ typeof decimalish +
115+ '(' +
116+ decimalish +
117+ ')' ,
118+ ) ;
105119 }
106120 }
107121
You can’t perform that action at this time.
0 commit comments