@@ -795,7 +795,11 @@ export class ParamType {
795
795
if ( ParamType . isParamType ( obj ) ) { return obj ; }
796
796
797
797
if ( typeof ( obj ) === "string" ) {
798
- return ParamType . from ( lex ( obj ) , allowIndexed ) ;
798
+ try {
799
+ return ParamType . from ( lex ( obj ) , allowIndexed ) ;
800
+ } catch ( error ) {
801
+ assertArgument ( false , "invalid param type" , "obj" , obj ) ;
802
+ }
799
803
800
804
} else if ( obj instanceof TokenString ) {
801
805
let type = "" , baseType = "" ;
@@ -1159,7 +1163,11 @@ export class EventFragment extends NamedFragment {
1159
1163
if ( EventFragment . isFragment ( obj ) ) { return obj ; }
1160
1164
1161
1165
if ( typeof ( obj ) === "string" ) {
1162
- return EventFragment . from ( lex ( obj ) ) ;
1166
+ try {
1167
+ return EventFragment . from ( lex ( obj ) ) ;
1168
+ } catch ( error ) {
1169
+ assertArgument ( false , "invalid event fragment" , "obj" , obj ) ;
1170
+ }
1163
1171
1164
1172
} else if ( obj instanceof TokenString ) {
1165
1173
const name = consumeName ( "event" , obj ) ;
@@ -1237,7 +1245,11 @@ export class ConstructorFragment extends Fragment {
1237
1245
if ( ConstructorFragment . isFragment ( obj ) ) { return obj ; }
1238
1246
1239
1247
if ( typeof ( obj ) === "string" ) {
1240
- return ConstructorFragment . from ( lex ( obj ) ) ;
1248
+ try {
1249
+ return ConstructorFragment . from ( lex ( obj ) ) ;
1250
+ } catch ( error ) {
1251
+ assertArgument ( false , "invalid constuctor fragment" , "obj" , obj ) ;
1252
+ }
1241
1253
1242
1254
} else if ( obj instanceof TokenString ) {
1243
1255
consumeKeywords ( obj , setify ( [ "constructor" ] ) ) ;
@@ -1300,7 +1312,11 @@ export class FallbackFragment extends Fragment {
1300
1312
if ( FallbackFragment . isFragment ( obj ) ) { return obj ; }
1301
1313
1302
1314
if ( typeof ( obj ) === "string" ) {
1303
- return FallbackFragment . from ( lex ( obj ) ) ;
1315
+ try {
1316
+ return FallbackFragment . from ( lex ( obj ) ) ;
1317
+ } catch ( error ) {
1318
+ assertArgument ( false , "invalid fallback fragment" , "obj" , obj ) ;
1319
+ }
1304
1320
1305
1321
} else if ( obj instanceof TokenString ) {
1306
1322
const errorObj = obj . toString ( ) ;
@@ -1472,7 +1488,11 @@ export class FunctionFragment extends NamedFragment {
1472
1488
if ( FunctionFragment . isFragment ( obj ) ) { return obj ; }
1473
1489
1474
1490
if ( typeof ( obj ) === "string" ) {
1475
- return FunctionFragment . from ( lex ( obj ) ) ;
1491
+ try {
1492
+ return FunctionFragment . from ( lex ( obj ) ) ;
1493
+ } catch ( error ) {
1494
+ assertArgument ( false , "invalid function fragment" , "obj" , obj ) ;
1495
+ }
1476
1496
1477
1497
} else if ( obj instanceof TokenString ) {
1478
1498
const name = consumeName ( "function" , obj ) ;
@@ -1553,7 +1573,11 @@ export class StructFragment extends NamedFragment {
1553
1573
*/
1554
1574
static from ( obj : any ) : StructFragment {
1555
1575
if ( typeof ( obj ) === "string" ) {
1556
- return StructFragment . from ( lex ( obj ) ) ;
1576
+ try {
1577
+ return StructFragment . from ( lex ( obj ) ) ;
1578
+ } catch ( error ) {
1579
+ assertArgument ( false , "invalid struct fragment" , "obj" , obj ) ;
1580
+ }
1557
1581
1558
1582
} else if ( obj instanceof TokenString ) {
1559
1583
const name = consumeName ( "struct" , obj ) ;
0 commit comments