File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,20 @@ final class DatabaseManager {
114114 }
115115
116116 // Create appropriate driver with effective connection
117- let driver = try DatabaseDriverFactory . createDriver ( for: effectiveConnection)
117+ let driver : DatabaseDriver
118+ do {
119+ driver = try DatabaseDriverFactory . createDriver ( for: effectiveConnection)
120+ } catch {
121+ // Close tunnel if SSH was established
122+ if connection. sshConfig. enabled {
123+ Task {
124+ try ? await SSHTunnelManager . shared. closeTunnel ( connectionId: connection. id)
125+ }
126+ }
127+ activeSessions. removeValue ( forKey: connection. id)
128+ currentSessionId = nil
129+ throw error
130+ }
118131
119132 do {
120133 try await driver. connect ( )
Original file line number Diff line number Diff line change @@ -1014,6 +1014,13 @@ struct ConnectionFormView: View {
10141014 } else {
10151015 Self . logger. error (
10161016 " Failed to connect: \( error. localizedDescription, privacy: . public) " )
1017+ NSApplication . shared. closeWindows ( withId: " main " )
1018+ openWindow ( id: " welcome " )
1019+ AlertHelper . showErrorSheet (
1020+ title: String ( localized: " Connection Failed " ) ,
1021+ message: error. localizedDescription,
1022+ window: nil
1023+ )
10171024 }
10181025 }
10191026 }
@@ -1035,6 +1042,13 @@ struct ConnectionFormView: View {
10351042 } catch {
10361043 Self . logger. error (
10371044 " Failed to connect after plugin install: \( error. localizedDescription, privacy: . public) " )
1045+ NSApplication . shared. closeWindows ( withId: " main " )
1046+ openWindow ( id: " welcome " )
1047+ AlertHelper . showErrorSheet (
1048+ title: String ( localized: " Connection Failed " ) ,
1049+ message: error. localizedDescription,
1050+ window: nil
1051+ )
10381052 }
10391053 }
10401054 }
You can’t perform that action at this time.
0 commit comments