Skip to content

Commit 1feceba

Browse files
committed
Add UnicodeUrlConvertError as struct
1 parent a460a50 commit 1feceba

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Sources/UnicodeURL/URL+Unicode.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
import Foundation
77
import IDNSDK
88

9-
enum UnicodeURLConvertError: Int {
10-
case none = 0
11-
case STD3NonLDH = 300
12-
case STD3Hyphen = 301
13-
case alreadyEncoded = 302
14-
case invalidDNSLength = 303
15-
case cicleCheck = 304
9+
public struct UnicodeURLConvertError: Error {
10+
public enum ConvertError: Int {
11+
case none = 0
12+
case STD3NonLDH = 300
13+
case STD3Hyphen = 301
14+
case alreadyEncoded = 302
15+
case invalidDNSLength = 303
16+
case cicleCheck = 304
17+
}
18+
19+
public let error: ConvertError
1620
}
1721

1822
public extension URL {
@@ -114,8 +118,9 @@ public extension URL {
114118
}
115119
}
116120

117-
if ret != XCODE_SUCCESS {
118-
throw NSError(domain:"kIFUnicodeURLErrorDomain", code:Int(ret), userInfo:nil)
121+
if ret != XCODE_SUCCESS,
122+
let error = UnicodeURLConvertError.ConvertError(rawValue: Int(ret)) {
123+
throw UnicodeURLConvertError(error: error)
119124
}
120125

121126
return hostname

0 commit comments

Comments
 (0)