From 72d58149f998b041037fcd01e7979576fed75def Mon Sep 17 00:00:00 2001 From: Bart Whiteley <@bwhiteley> Date: Sat, 12 Nov 2016 16:08:10 -0700 Subject: [PATCH] Better error for URLs --- Sources/ValueType.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/ValueType.swift b/Sources/ValueType.swift index 90c7586..e147c05 100644 --- a/Sources/ValueType.swift +++ b/Sources/ValueType.swift @@ -81,8 +81,11 @@ extension Set where Element: ValueType { extension URL: ValueType { public static func value(from object: Any) throws -> URL { - guard let urlString = object as? String, let objectValue = URL(string: urlString) else { - throw MarshalError.typeMismatch(expected: self, actual: type(of: object)) + guard let urlString = object as? String else { + throw MarshalError.typeMismatch(expected: String.self, actual: type(of: object)) + } + guard let objectValue = URL(string: urlString) else { + throw MarshalError.typeMismatch(expected: "valid URL", actual: urlString) } return objectValue }