This commit is contained in:
Trey t
2023-06-22 20:27:21 -05:00
parent cf22aeee19
commit a43acc9c27
12 changed files with 205 additions and 36 deletions

View File

@@ -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
}
}