Skip to content

Commit

Permalink
Update Chat Sample to handle unsupportedUserLocation case (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard authored Jan 26, 2024
1 parent 07059df commit 84596eb
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ struct ErrorDetailsView: View {
)
}

case GenerateContentError.unsupportedUserLocation:
Section("Error Type") {
Text("Unsupported User Location")
}

Section("Details") {
SubtitleFormRow(title: "Error description", value: error.localizedDescription)
SubtitleMarkdownFormRow(
title: "Help",
value: """
The API is unsupported in your location (country / territory); please see the list of
[available regions](https://ai.google.dev/available_regions#available_regions).
"""
)
}

default:
Section("Error Type") {
Text("Some other error")
Expand Down Expand Up @@ -225,3 +241,7 @@ struct ErrorDetailsView: View {
#Preview("Invalid API Key") {
ErrorDetailsView(error: GenerateContentError.invalidAPIKey)
}

#Preview("Unsupported User Location") {
ErrorDetailsView(error: GenerateContentError.unsupportedUserLocation)
}

0 comments on commit 84596eb

Please sign in to comment.