Created
August 8, 2022 16:17
-
-
Save LukaszDziwosz/129098e95ae12b6a1835e04378ffb5a4 to your computer and use it in GitHub Desktop.
GitHub search with Alamofire
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
import SwiftUI | |
enum ErrorType { | |
case decoding | |
case noInternet | |
case backend(Int) | |
} | |
struct ErrorView: View { | |
let error: ErrorType | |
var body: some View { | |
VStack { | |
Text("Something went wrong") | |
.font(.title) | |
.padding() | |
Group { | |
switch error { | |
case .decoding: | |
Text("Please contact developer") | |
case .noInternet: | |
Text("Please check your internet connection") | |
case .backend(let code): | |
switch code { | |
case 403: | |
Text("Github API limit reached, wait a second") | |
case 503: | |
Text("Service unavailable") | |
default: | |
Text("Server error code: \(code)") | |
} | |
} | |
} | |
.padding() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment