From c3abce7344cbfcd53cbd73a9ab76764e904f20eb Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Fri, 25 Oct 2024 15:46:40 -0400 Subject: [PATCH] Format errors for readability --- Sources/WebDriver/ErrorResponse.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/WebDriver/ErrorResponse.swift b/Sources/WebDriver/ErrorResponse.swift index 7db02c5..8e19113 100644 --- a/Sources/WebDriver/ErrorResponse.swift +++ b/Sources/WebDriver/ErrorResponse.swift @@ -1,7 +1,17 @@ -public struct ErrorResponse: Codable, Error { +/// A response received when an error occurs when processing a request. +public struct ErrorResponse: Codable, Error, CustomStringConvertible { public var status: Status public var value: Value + public var description: String { + var str = "Error \(status.rawValue)" + if let error = value.error { + str += " (\(error))" + } + str += ": \(value.message)" + return str + } + // https://www.selenium.dev/documentation/legacy/json_wire_protocol/#response-status-codes public struct Status: Codable, Hashable, RawRepresentable { public var rawValue: Int