WIP
This commit is contained in:
@@ -13,7 +13,7 @@ enum FetchableError: Error {
|
||||
case decodeError(Error)
|
||||
case endOfFileError
|
||||
case noPostData
|
||||
case statusError(Int)
|
||||
case statusError(Int, String?)
|
||||
}
|
||||
|
||||
protocol Fetchable {
|
||||
@@ -86,7 +86,12 @@ extension Postable {
|
||||
|
||||
if let httpRespone = response as? HTTPURLResponse {
|
||||
if httpRespone.statusCode != 201 {
|
||||
completion(.failure(.statusError(httpRespone.statusCode)))
|
||||
var returnStr: String?
|
||||
if let data = data {
|
||||
returnStr = String(data: data, encoding: .utf8)
|
||||
}
|
||||
|
||||
completion(.failure(.statusError(httpRespone.statusCode, returnStr)))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user