Skip to content

Instantly share code, notes, and snippets.

@LukaszDziwosz
Created August 8, 2022 16:17
Show Gist options
  • Save LukaszDziwosz/129098e95ae12b6a1835e04378ffb5a4 to your computer and use it in GitHub Desktop.
Save LukaszDziwosz/129098e95ae12b6a1835e04378ffb5a4 to your computer and use it in GitHub Desktop.
GitHub search with Alamofire
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