Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

iOSDevloper iosdroid

🏠
Working from home
View GitHub Profile
@iosdroid
iosdroid / Alamofire.request.error.handling.swift
Created Mar 29, 2021 — forked from perlguy99/Alamofire.request.error.handling.swift
Alamofire Request Error Handling - From their documentation
View Alamofire.request.error.handling.swift
Alamofire.request(urlString).responseJSON { response in
guard case let .failure(error) = response.result else { return }
if let error = error as? AFError {
switch error {
case .invalidURL(let url):
print("Invalid URL: \(url) - \(error.localizedDescription)")
case .parameterEncodingFailed(let reason):
print("Parameter encoding failed: \(error.localizedDescription)")
print("Failure Reason: \(reason)")