Skip to content

Commit 478afdf

Browse files
author
Jeremy Chiang
authored
Merge pull request #43 from steamclock/jc/add-error-codes
Add error codes
2 parents 6f5acb8 + cf43c15 commit 478afdf

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

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](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.8.2] - 2020-03-02
8+
### Added
9+
- Added missing error codes
10+
711
## [0.8.1] - 2020-02-11
812
### Changed
913
- Lowered minimum iOS target to 11

Netable.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |s|
22
s.name = 'Netable'
3-
s.version = '0.8.1'
3+
s.version = '0.8.2'
44
s.summary = 'A simple and swifty networking library.'
55
s.description = 'Netable is a simple Swift framework for working with both simple and non-REST-compliant HTTP endpoints.'
66
s.homepage = 'https://github.com/steamclock/netable/'
77
s.license = { :type => 'MIT', :file => 'LICENSE' }
88
s.author = { 'Brendan Lensink' => 'brendan@steamclock.com' }
9-
s.source = { :git => 'https://github.com/steamclock/netable.git', :tag => 'v0.8.1' }
9+
s.source = { :git => 'https://github.com/steamclock/netable.git', :tag => 'v0.8.2' }
1010
s.ios.deployment_target = '11.0'
1111
s.osx.deployment_target = '10.14'
1212
s.source_files = 'Netable/Netable/*.{swift,h,m}'

Netable/Netable.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@
586586
"@executable_path/Frameworks",
587587
"@loader_path/Frameworks",
588588
);
589-
MARKETING_VERSION = 0.8.1;
589+
MARKETING_VERSION = 0.8.2;
590590
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.Netable;
591591
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
592592
SKIP_INSTALL = YES;
@@ -616,7 +616,7 @@
616616
"@executable_path/Frameworks",
617617
"@loader_path/Frameworks",
618618
);
619-
MARKETING_VERSION = 0.8.1;
619+
MARKETING_VERSION = 0.8.2;
620620
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.Netable;
621621
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
622622
SKIP_INSTALL = YES;

Netable/Netable/Error.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@ public enum NetableError: Error {
2121
}
2222

2323
extension NetableError: LocalizedError {
24+
public var errorCode: Int? {
25+
switch self {
26+
case .codingError:
27+
return 0
28+
case .decodingError:
29+
return 1
30+
case .httpError(let statusCode, _):
31+
return statusCode < 100 ? 2 : statusCode
32+
case .malformedURL:
33+
return 3
34+
case .requestFailed:
35+
return 4
36+
case .wrongServer:
37+
return 5
38+
case .noData:
39+
return 6
40+
case .resourceExtractionError:
41+
return 7
42+
case .unknownError:
43+
return 8
44+
}
45+
}
46+
2447
public var errorDescription: String? {
2548
switch self {
2649
case .codingError(let message):

0 commit comments

Comments
 (0)