 // Exception types
 //
 enum Parameter: ErrorType {
-    case Invalid
+    case InvalidHexCharacterCount
+    case InvalidHexCharacter(char: Character)
+    case InvalidHexString(str: String)
 }
  
 //


    // input string should have an even number of characters
    guard (input.characters.count % 2 == 0) else {
        throw Parameter.Invalid
    }

    // input string should only have hexadecimal characters
    for char in input.lowercaseString.characters {
        guard hex.characters.contains(char) else {
            throw Parameter.Invalid
        }
    }

    // extract raw bytes from input
    var bytes = [UInt8](count: input.characters.count / 2, repeatedValue: 0)
    var index = input.startIndex
    for _ in 1...(input.characters.count / 2) {
        var digit = String(input[index]) + String(input[index.successor()])
        index = index.successor().successor()
    }


    return bytes
}


        return ""
    }

    let bytes = try? convertHexToBytes(input)

    var result = ""

