File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " typed-string-interpolation " : patch
3
+ ---
4
+
5
+ Throw Error objects
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export function stringInterpolation<
54
54
raw : rawOutput = false ,
55
55
} : StringInterpolationOptions < OptionRaw > = { }
56
56
) : StringInterpolationReturn < VariableValue , OptionRaw > {
57
- if ( ! string && sanity ) throw "Empty string"
57
+ if ( ! string && sanity ) throw new Error ( "Empty string" )
58
58
59
59
// Find all variables within string
60
60
const stringVariables = matchAllPolyfill ( string , pattern )
@@ -68,11 +68,11 @@ export function stringInterpolation<
68
68
const variableKeys = Object . keys ( variables )
69
69
// Checks whether variables parsed from string exist in passed argument
70
70
if ( stringVariables . length !== variableKeys . length )
71
- throw "Variable count mismatch"
71
+ throw new Error ( "Variable count mismatch" )
72
72
for ( const regExpMatchArray of stringVariables ) {
73
73
const variableKeyInString = regExpMatchArray [ 1 ]
74
74
if ( variableKeyInString && ! variableKeys . includes ( variableKeyInString ) )
75
- throw `Variable '${ variableKeyInString } ' not found`
75
+ throw new Error ( `Variable '${ variableKeyInString } ' not found` )
76
76
}
77
77
}
78
78
You can’t perform that action at this time.
0 commit comments