diff --git a/Sources/Swiftfall/Swiftfall.swift b/Sources/Swiftfall/Swiftfall.swift index b0292f8..b8b30a7 100644 --- a/Sources/Swiftfall/Swiftfall.swift +++ b/Sources/Swiftfall/Swiftfall.swift @@ -109,12 +109,20 @@ public class Swiftfall { struct ScryfallError: Codable, Error, CustomStringConvertible { let code: String - let type: String + let type: String? let status: Int + let warnings: [String]? + let details: String public var description: String { - return "Error: \(code)\nDetails: \(details)\n" + var text = "Error: \(code)\nDetails: \(details)\n" + if let warns = warnings { + for warning in warns { + text += warning + "\n" + } + } + return text } } diff --git a/Tests/Tests.swift b/Tests/Tests.swift index c627cb5..7c6a908 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -289,6 +289,14 @@ class Tests: XCTestCase { } } + func testErrorWarning() throws { + do { + _ = try Swiftfall.getCatalog(catalog: "types") + } catch { + print(error) + } + } + func testAutocomplete() throws { do { _ = try Swiftfall.autocomplete("Thal")