@@ -44,7 +44,7 @@ struct Scanner {
4444 case literalCharacterSet:
4545 return try scanLiteralComponent ( )
4646 default :
47- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Unexpected character " )
47+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Unexpected character " )
4848 }
4949 }
5050
@@ -63,7 +63,7 @@ struct Scanner {
6363 let expressionOperator : ExpressionOperator
6464 if expressionOperatorCharacterSet. contains ( unicodeScalars [ currentIndex] ) {
6565 guard let `operator` = ExpressionOperator ( rawValue: unicodeScalars [ currentIndex] ) else {
66- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Unsupported Operator " )
66+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Unsupported Operator " )
6767 }
6868 expressionOperator = `operator`
6969 currentIndex = unicodeScalars. index ( after: currentIndex)
@@ -81,13 +81,13 @@ struct Scanner {
8181 let variableName = try scanVariableName ( )
8282
8383 if currentIndex == unicodeScalars. endIndex {
84- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Unterminated Expression " )
84+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Unterminated Expression " )
8585 }
8686
8787 let modifier = try scanVariableModifier ( )
8888
8989 if currentIndex == unicodeScalars. endIndex {
90- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Unterminated Expression " )
90+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Unterminated Expression " )
9191 }
9292
9393 variableList. append ( VariableSpec ( name: variableName, modifier: modifier) )
@@ -99,7 +99,7 @@ struct Scanner {
9999 currentIndex = unicodeScalars. index ( after: currentIndex)
100100 complete = true
101101 default :
102- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Unexpected Character in Expression " )
102+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Unexpected Character in Expression " )
103103 }
104104 }
105105
@@ -110,17 +110,17 @@ struct Scanner {
110110 let endIndex = scanUpTo ( characterSet: invertedVarnameCharacterSet)
111111 let variableName = string [ currentIndex..< endIndex]
112112 if variableName. isEmpty {
113- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Empty Variable Name " )
113+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Empty Variable Name " )
114114 } else if variableName. starts ( with: " . " ) {
115- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Variable Name Cannot Begin With '.' " )
115+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Variable Name Cannot Begin With '.' " )
116116 }
117117 var remainingVariableName = variableName
118118 while let index = remainingVariableName. firstIndex ( of: " % " ) {
119119 let secondIndex = remainingVariableName. index ( after: index)
120120 let thirdIndex = remainingVariableName. index ( after: secondIndex)
121121 if !hexCharacterSet. contains ( unicodeScalars [ secondIndex] ) ||
122122 !hexCharacterSet. contains ( unicodeScalars [ thirdIndex] ) {
123- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " % must be percent-encoded in variable name " )
123+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " % must be percent-encoded in variable name " )
124124 }
125125 let nextIndex = remainingVariableName. index ( after: thirdIndex)
126126 remainingVariableName = remainingVariableName [ nextIndex... ]
@@ -139,16 +139,16 @@ struct Scanner {
139139 let endIndex = scanUpTo ( characterSet: invertedDecimalDigitsCharacterSet)
140140 let lengthString = string [ currentIndex..< endIndex]
141141 if lengthString. isEmpty {
142- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Prefix length not specified " )
142+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Prefix length not specified " )
143143 }
144144 if lengthString. first == " 0 " {
145- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Prefix length cannot begin with 0 " )
145+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Prefix length cannot begin with 0 " )
146146 }
147147 if lengthString. count > 4 {
148- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Prefix modifier length too large " )
148+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Prefix modifier length too large " )
149149 }
150150 guard let length = Int ( lengthString) else {
151- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " Cannot parse prefix modifier length " )
151+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " Cannot parse prefix modifier length " )
152152 }
153153 currentIndex = endIndex
154154 return . prefix( length: length)
@@ -175,7 +175,7 @@ struct Scanner {
175175
176176 if !hexCharacterSet. contains ( unicodeScalars [ secondIndex] ) ||
177177 !hexCharacterSet. contains ( unicodeScalars [ thirdIndex] ) {
178- throw URITemplate . Error. malformedTemplate ( position: currentIndex, reason: " % must be percent-encoded in literal " )
178+ throw URITemplate . Error ( type : . malformedTemplate, position: currentIndex, reason: " % must be percent-encoded in literal " )
179179 }
180180
181181 currentIndex = unicodeScalars. index ( after: thirdIndex)
0 commit comments