Conversation
|
|
||
| // Convert an Error to a RequestError, mapping HTTP error codes over if given a | ||
| // SwiftyRequest.RestError. Decorate the RequestError with Data if provided | ||
| fileprivate func constructRequestError(from error: Error, data: Data?) -> RequestError { |
There was a problem hiding this comment.
As discussed, would this be better as (uncompiled):
extension RequestError {
init(from error: Error, data: Data?) {
self = .clientErrorUnknown
if let restError = error as? RestError {
init(restError: restError)
}
if let data = data {
do {
// TODO: Check Content-Type for format, assuming JSON for now
try init(requestError, bodyData: data, format: .json)
} catch {
// Do nothing, format not supported
}
}
}
}Perhaps in RequestErrorExtension.swift.
There was a problem hiding this comment.
After discussing this, we decided that this code was pretty specific to the file it was in and may not be generally useful and so were not sure if moving it out / to an init() is necessary.
|
Waiting for Kitura to release a tagged version with the required router features for this to work. |
e2d1f43 to
169dc7c
Compare
Codecov Report
@@ Coverage Diff @@
## master #18 +/- ##
==========================================
+ Coverage 71.96% 80.15% +8.18%
==========================================
Files 2 2
Lines 132 131 -1
==========================================
+ Hits 95 105 +10
+ Misses 37 26 -11
Continue to review full report at Codecov.
|
|
Replaced by #30 as KituraKit's current release process requires we merge to |
Add support for populating/decoding the body of a RequestError.
Requires: Kitura/SwiftyRequest#18