-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NetworkErrorConvertible + convinece init
- Loading branch information
1 parent
829f594
commit a0e2245
Showing
3 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Lukas Schmidt on 13.10.23. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol NetworkErrorConvertible: Error { | ||
|
||
init(networkError: NetworkError) | ||
|
||
} |
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,18 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Lukas Schmidt on 13.10.23. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension ResourceWithError where E: NetworkErrorConvertible { | ||
|
||
init(request: URLRequest, parse: @escaping (Data) throws -> Model) { | ||
self.request = request | ||
self.parse = parse | ||
self.mapError = { E(networkError: $0) } | ||
} | ||
|
||
} |