Skip to content

Commit

Permalink
Merge pull request #43 from steamclock/jc/add-error-codes
Browse files Browse the repository at this point in the history
Add error codes
  • Loading branch information
Jeremy Chiang authored Mar 2, 2020
2 parents 6f5acb8 + cf43c15 commit 478afdf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.8.2] - 2020-03-02
### Added
- Added missing error codes

## [0.8.1] - 2020-02-11
### Changed
- Lowered minimum iOS target to 11
Expand Down
4 changes: 2 additions & 2 deletions Netable.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = 'Netable'
s.version = '0.8.1'
s.version = '0.8.2'
s.summary = 'A simple and swifty networking library.'
s.description = 'Netable is a simple Swift framework for working with both simple and non-REST-compliant HTTP endpoints.'
s.homepage = 'https://github.com/steamclock/netable/'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Brendan Lensink' => '[email protected]' }
s.source = { :git => 'https://github.com/steamclock/netable.git', :tag => 'v0.8.1' }
s.source = { :git => 'https://github.com/steamclock/netable.git', :tag => 'v0.8.2' }
s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.14'
s.source_files = 'Netable/Netable/*.{swift,h,m}'
Expand Down
4 changes: 2 additions & 2 deletions Netable/Netable.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.8.1;
MARKETING_VERSION = 0.8.2;
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.Netable;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -616,7 +616,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.8.1;
MARKETING_VERSION = 0.8.2;
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.Netable;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
23 changes: 23 additions & 0 deletions Netable/Netable/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ public enum NetableError: Error {
}

extension NetableError: LocalizedError {
public var errorCode: Int? {
switch self {
case .codingError:
return 0
case .decodingError:
return 1
case .httpError(let statusCode, _):
return statusCode < 100 ? 2 : statusCode
case .malformedURL:
return 3
case .requestFailed:
return 4
case .wrongServer:
return 5
case .noData:
return 6
case .resourceExtractionError:
return 7
case .unknownError:
return 8
}
}

public var errorDescription: String? {
switch self {
case .codingError(let message):
Expand Down

0 comments on commit 478afdf

Please sign in to comment.