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<
5454 raw : rawOutput = false ,
5555 } : StringInterpolationOptions < OptionRaw > = { }
5656) : StringInterpolationReturn < VariableValue , OptionRaw > {
57- if ( ! string && sanity ) throw "Empty string"
57+ if ( ! string && sanity ) throw new Error ( "Empty string" )
5858
5959 // Find all variables within string
6060 const stringVariables = matchAllPolyfill ( string , pattern )
@@ -68,11 +68,11 @@ export function stringInterpolation<
6868 const variableKeys = Object . keys ( variables )
6969 // Checks whether variables parsed from string exist in passed argument
7070 if ( stringVariables . length !== variableKeys . length )
71- throw "Variable count mismatch"
71+ throw new Error ( "Variable count mismatch" )
7272 for ( const regExpMatchArray of stringVariables ) {
7373 const variableKeyInString = regExpMatchArray [ 1 ]
7474 if ( variableKeyInString && ! variableKeys . includes ( variableKeyInString ) )
75- throw `Variable '${ variableKeyInString } ' not found`
75+ throw new Error ( `Variable '${ variableKeyInString } ' not found` )
7676 }
7777 }
7878
You can’t perform that action at this time.
0 commit comments