diff --git a/Changelog.md b/Changelog.md index 928d20f..570e8e2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.2] - 2020-02-17 +### Fixed +- Decode errors within responses + ## [0.1.1] - 2020-01-31 ### Fixed - Module/class name collision which caused Failed to load module 'MailchimpSDK' error when integrating. diff --git a/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj b/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj index f83fb06..df16858 100644 --- a/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj +++ b/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj @@ -428,7 +428,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 0.1.1; + MARKETING_VERSION = 0.1.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -488,7 +488,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 0.1.1; + MARKETING_VERSION = 0.1.2; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; diff --git a/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift b/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift index 158d55d..f601ab2 100755 --- a/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift +++ b/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift @@ -156,6 +156,10 @@ struct AnzeeAPI: API { } else { completionBlock(.failure(.requestError(err: err))) } + } else if let jsonData = data, let errorResponse = try? JSONDecoder().decode(APIErrorResponse.self, from: jsonData) { + completionBlock(.failure(.apiError(response: errorResponse))) + } else if let httpResponse = response as? HTTPURLResponse, !(200..<300).contains(httpResponse.statusCode) { + completionBlock(.failure(.apiError(response: APIErrorResponse(status: 0, type: "Unexpected response", detail: "")))) } else if let jsonData = data { completionBlock(.success(jsonData)) } else { diff --git a/MailchimpSDK/MailchimpSDK/SDK/MailchimpSDK.swift b/MailchimpSDK/MailchimpSDK/SDK/MailchimpSDK.swift index 63b0bab..c70329e 100644 --- a/MailchimpSDK/MailchimpSDK/SDK/MailchimpSDK.swift +++ b/MailchimpSDK/MailchimpSDK/SDK/MailchimpSDK.swift @@ -29,7 +29,7 @@ public class MailchimpSDK: NSObject { public static var debugMode: Bool = false /// Version of this SDK. - public static let version: String = "0.1.1" + public static let version: String = "0.1.2" /// The API protocol conforming object that processes requests for this class. static var api: API?