-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Make StackError a struct (#49)
Co-authored-by: danthorpe <[email protected]>
- Loading branch information
Showing
15 changed files
with
236 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Sources/Networking/Errors/StackError+NetworkingError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Foundation | ||
|
||
extension StackError: NetworkingError { | ||
package var request: HTTPRequestData { | ||
switch info { | ||
case let .request(request): | ||
return request | ||
case let .response(response): | ||
return response.request | ||
} | ||
} | ||
|
||
package var response: HTTPResponseData? { | ||
switch info { | ||
case .request: | ||
return nil | ||
case let .response(response): | ||
return response | ||
} | ||
} | ||
|
||
package var requestDidTimeout: HTTPRequestData? { | ||
guard case .timeout = kind, case let .request(request) = info else { | ||
return nil | ||
} | ||
return request | ||
} | ||
|
||
package var isUnauthorizedResponse: HTTPResponseData? { | ||
if case .unauthorized = kind, case let .response(response) = info { | ||
return response | ||
} else if let response, response.status == .unauthorized { | ||
return response | ||
} | ||
return nil | ||
} | ||
} |
Oops, something went wrong.