mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 16:26:04 +00:00
33 lines
843 B
Swift
33 lines
843 B
Swift
//
|
|
// SyncDatabaseError.swift
|
|
// SyncDatabase
|
|
//
|
|
// Created by Brent Simmons on 9/16/26.
|
|
//
|
|
|
|
import Foundation
|
|
import RSDatabaseObjC
|
|
|
|
/// Sync database failure.
|
|
///
|
|
/// Deliberately not localized (to be used with bug reports).
|
|
public enum SyncDatabaseError: LocalizedError {
|
|
|
|
case sqliteError(operation: String, code: Int, message: String)
|
|
|
|
public var errorDescription: String? {
|
|
switch self {
|
|
case .sqliteError(let operation, let code, let message):
|
|
return "\(operation) failed — SQLite \(code): \(message)"
|
|
}
|
|
}
|
|
}
|
|
|
|
extension FMDatabase {
|
|
|
|
/// Current SQLite error. Call before `rollback()` which overwrites the last-error state.
|
|
func syncDatabaseError(operation: String) -> SyncDatabaseError {
|
|
SyncDatabaseError.sqliteError(operation: operation, code: Int(lastErrorCode()), message: lastErrorMessage() ?? "unknown")
|
|
}
|
|
}
|