Skip to content

Commit 08efbae

Browse files
Improved error logs by adding title to APIErrorResponse and makin… (#63)
* Improved error logs by adding `title` to `APIErrorResponse` and making some values Optional. * Bumped version to 2.0.3.
1 parent 6bbf3b8 commit 08efbae

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.0.3] - 2021-02-16
8+
### Fixed
9+
- API error response parsing
10+
711
## [2.0.2] - 2020-11-19
812
### Added
913
- Swift Package Support

MailchimpSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'MailchimpSDK'
11-
s.version = '2.0.2'
11+
s.version = '2.0.3'
1212
s.summary = 'Mailchimp SDK for iOS'
1313

1414
s.description = <<-DESC

Sources/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@
512512
"@executable_path/Frameworks",
513513
"@loader_path/Frameworks",
514514
);
515-
MARKETING_VERSION = 2.0.2;
515+
MARKETING_VERSION = 2.0.3;
516516
PRODUCT_BUNDLE_IDENTIFIER = com.theRocketScienceGroup.MailchimpSDK;
517517
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
518518
SKIP_INSTALL = YES;
@@ -541,7 +541,7 @@
541541
"@executable_path/Frameworks",
542542
"@loader_path/Frameworks",
543543
);
544-
MARKETING_VERSION = 2.0.2;
544+
MARKETING_VERSION = 2.0.3;
545545
PRODUCT_BUNDLE_IDENTIFIER = com.theRocketScienceGroup.MailchimpSDK;
546546
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
547547
SKIP_INSTALL = YES;
@@ -561,7 +561,7 @@
561561
"@executable_path/Frameworks",
562562
"@loader_path/Frameworks",
563563
);
564-
MARKETING_VERSION = 2.0.2;
564+
MARKETING_VERSION = 2.0.3;
565565
PRODUCT_BUNDLE_IDENTIFIER = "com.theRocketScienceGroup.Mailchimp-SDKTests";
566566
PRODUCT_NAME = "$(TARGET_NAME)";
567567
SWIFT_VERSION = 5.0;
@@ -580,7 +580,7 @@
580580
"@executable_path/Frameworks",
581581
"@loader_path/Frameworks",
582582
);
583-
MARKETING_VERSION = 2.0.2;
583+
MARKETING_VERSION = 2.0.3;
584584
PRODUCT_BUNDLE_IDENTIFIER = "com.theRocketScienceGroup.Mailchimp-SDKTests";
585585
PRODUCT_NAME = "$(TARGET_NAME)";
586586
SWIFT_VERSION = 5.0;

Sources/MailchimpSDK/MailchimpSDK/Core/Networking/APIErrorResponse.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import Foundation
1919

2020
/// Basic struct to parse any possible API error responses
2121
public struct APIErrorResponse: Codable {
22+
public let title: String?
2223
public let status: Int
23-
public let type: String
24-
public let detail: String
24+
public let type: String?
25+
public let detail: String?
2526
}

Sources/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ struct AnzeeAPI: API {
159159
} else if let jsonData = data, let errorResponse = try? JSONDecoder().decode(APIErrorResponse.self, from: jsonData) {
160160
completionBlock(.failure(.apiError(response: errorResponse)))
161161
} else if let httpResponse = response as? HTTPURLResponse, !(200..<300).contains(httpResponse.statusCode) {
162-
completionBlock(.failure(.apiError(response: APIErrorResponse(status: 0, type: "Unexpected response", detail: ""))))
162+
completionBlock(.failure(.apiError(response: APIErrorResponse(title: nil,
163+
status: httpResponse.statusCode,
164+
type: "Unexpected response",
165+
detail: nil))))
163166
} else if let jsonData = data {
164167
completionBlock(.success(jsonData))
165168
} else {

0 commit comments

Comments
 (0)