Skip to content

Commit bbc9532

Browse files
committed
fix: add logging to 7 silent try?/catch blocks in critical paths
- PluginManager: log uninstall failure before reinstall - ExportService: log cleanup failure for partial export files (2 sites) - DatabaseDriver: log per-table column fetch failure for autocomplete - DatabaseManager: log ping and reconnect failures - SQLSchemaProvider: log column fetch failure for autocomplete
1 parent 42b04fc commit bbc9532

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

TablePro/Core/Autocomplete/SQLSchemaProvider.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
//
77

88
import Foundation
9+
import os
910
import TableProPluginKit
1011

1112
/// Provides cached database schema information for autocomplete
1213
actor SQLSchemaProvider {
14+
private static let logger = Logger(subsystem: "com.TablePro", category: "SQLSchemaProvider")
1315
// MARK: - Properties
1416

1517
private var tables: [TableInfo] = []
@@ -74,6 +76,7 @@ actor SQLSchemaProvider {
7476
evictIfNeeded()
7577
return columns
7678
} catch {
79+
Self.logger.debug("Column fetch failed for autocomplete: \(error.localizedDescription)")
7780
return []
7881
}
7982
}

TablePro/Core/Database/DatabaseDriver.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ extension DatabaseDriver {
272272
let columns = try await fetchColumns(table: table.name)
273273
result[table.name] = columns
274274
} catch {
275-
// Skip tables whose columns can't be fetched
275+
Logger(subsystem: "com.TablePro", category: "DatabaseDriver")
276+
.debug("Skipping columns for table '\(table.name)': \(error.localizedDescription)")
276277
}
277278
}
278279
return result

TablePro/Core/Database/DatabaseManager.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ final class DatabaseManager {
616616
_ = try await mainDriver.execute(query: "SELECT 1")
617617
return true
618618
} catch {
619+
Self.logger.debug("Ping failed: \(error.localizedDescription)")
619620
return false
620621
}
621622
},
@@ -632,6 +633,7 @@ final class DatabaseManager {
632633
}
633634
return true
634635
} catch {
636+
Self.logger.debug("Reconnect failed: \(error.localizedDescription)")
635637
return false
636638
}
637639
},

TablePro/Core/Plugins/PluginManager.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,11 @@ final class PluginManager {
929929
}
930930
Self.logger.warning("Plugin '\(existingEntry.id)' exists but driver not registered, reinstalling")
931931
if existingEntry.source == .userInstalled {
932-
try? uninstallPlugin(id: existingEntry.id)
932+
do {
933+
try uninstallPlugin(id: existingEntry.id)
934+
} catch {
935+
Self.logger.warning("Failed to uninstall plugin '\(existingEntry.id)' before reinstall: \(error.localizedDescription)")
936+
}
933937
}
934938
}
935939

TablePro/Core/Services/Export/ExportService.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ final class ExportService {
180180
progress: progress
181181
)
182182
} catch {
183-
try? FileManager.default.removeItem(at: url)
183+
do {
184+
try FileManager.default.removeItem(at: url)
185+
} catch {
186+
Self.logger.warning("Failed to clean up export file: \(error.localizedDescription)")
187+
}
184188
state.errorMessage = error.localizedDescription
185189
throw error
186190
}
@@ -260,7 +264,11 @@ final class ExportService {
260264
progress: progress
261265
)
262266
} catch {
263-
try? FileManager.default.removeItem(at: url)
267+
do {
268+
try FileManager.default.removeItem(at: url)
269+
} catch {
270+
Self.logger.warning("Failed to clean up export file: \(error.localizedDescription)")
271+
}
264272
state.errorMessage = error.localizedDescription
265273
throw error
266274
}

0 commit comments

Comments
 (0)