1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- @ testable import FirebaseAI
15+ import FirebaseAI
1616import MarkdownUI
1717import SwiftUI
1818
@@ -22,10 +22,8 @@ struct LiveErrorDetailsView: View {
2222 var body : some View {
2323 NavigationView {
2424 Form {
25- if let title = error. title {
26- Section ( " Error type " ) {
27- Text ( title)
28- }
25+ Section ( " Error type " ) {
26+ Text ( " \( error. self) " )
2927 }
3028
3129 Section ( " Details " ) {
@@ -50,36 +48,14 @@ private struct SubtitleFormRow: View {
5048 }
5149}
5250
53- private extension Error {
54- var title : String ? {
55- switch self {
56- case _ as LiveSessionSetupError :
57- " Failed to set up live session "
58- case _ as LiveSessionLostConnectionError :
59- " Lost connection to the model "
60- case _ as LiveSessionUnexpectedClosureError :
61- " Session was closed "
62- case _ as LiveSessionUnsupportedMessageError :
63- " Unsupported model message "
64- default :
65- nil
66- }
51+ struct ExampleLiveSessionError : Error , CustomNSError {
52+ public var errorUserInfo : [ String : Any ] {
53+ [
54+ NSLocalizedDescriptionKey: " The live session lost connection to the server. "
55+ ]
6756 }
6857}
6958
7059#Preview( " Live error " ) {
71- let cause = NSError ( domain: " network.api " , code: 1 , userInfo: [
72- NSLocalizedDescriptionKey: " Network timed out. " ,
73- ] )
74- let error = LiveSessionLostConnectionError ( underlyingError: cause)
75-
76- LiveErrorDetailsView ( error: error)
77- }
78-
79- #Preview( " Unexpected error " ) {
80- let error = NSError ( domain: " network.api " , code: 1 , userInfo: [
81- NSLocalizedDescriptionKey: " Network timed out. " ,
82- ] )
83-
84- LiveErrorDetailsView ( error: error)
60+ LiveErrorDetailsView ( error: ExampleLiveSessionError ( ) )
8561}
0 commit comments