Skip to content

Commit

Permalink
Add UnicodeUrlConvertError as struct
Browse files Browse the repository at this point in the history
  • Loading branch information
rizwankce committed Sep 22, 2020
1 parent a460a50 commit 1feceba
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Sources/UnicodeURL/URL+Unicode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import Foundation
import IDNSDK

enum UnicodeURLConvertError: Int {
case none = 0
case STD3NonLDH = 300
case STD3Hyphen = 301
case alreadyEncoded = 302
case invalidDNSLength = 303
case cicleCheck = 304
public struct UnicodeURLConvertError: Error {
public enum ConvertError: Int {
case none = 0
case STD3NonLDH = 300
case STD3Hyphen = 301
case alreadyEncoded = 302
case invalidDNSLength = 303
case cicleCheck = 304
}

public let error: ConvertError
}

public extension URL {
Expand Down Expand Up @@ -114,8 +118,9 @@ public extension URL {
}
}

if ret != XCODE_SUCCESS {
throw NSError(domain:"kIFUnicodeURLErrorDomain", code:Int(ret), userInfo:nil)
if ret != XCODE_SUCCESS,
let error = UnicodeURLConvertError.ConvertError(rawValue: Int(ret)) {
throw UnicodeURLConvertError(error: error)
}

return hostname
Expand Down

0 comments on commit 1feceba

Please sign in to comment.