From 22c173c658dc00996bafc218e558fa97f4d8d69b Mon Sep 17 00:00:00 2001 From: Yuki Takei Date: Wed, 12 Jul 2017 21:33:53 +0900 Subject: [PATCH] show body data for the error response --- Sources/HexavilleAuth/HexaviileAuth.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sources/HexavilleAuth/HexaviileAuth.swift b/Sources/HexavilleAuth/HexaviileAuth.swift index 082593f..520ff0e 100644 --- a/Sources/HexavilleAuth/HexaviileAuth.swift +++ b/Sources/HexavilleAuth/HexaviileAuth.swift @@ -7,6 +7,23 @@ public enum HexavilleAuthError: Error { case responseError(Response) } +extension HexavilleAuthError: CustomStringConvertible { + public var description: String { + switch self { + case .responseError(let response): + var str = "" + str += "\(response)" + str += "\n" + str += "\n" + str += String(data: response.body.asData(), encoding: .utf8) ?? "Unknown Error" + return str + + default: + return "\(self)" + } + } +} + public enum CredentialProviderType { case oauth2(OAuth2AuthorizationProvidable) case oauth1(OAuth1AuthorizationProvidable)