Skip to content

Commit a2fc60c

Browse files
authored
Change SQLiteError.onInternalError to include inner error instead of String (#31)
1 parent 6d7c469 commit a2fc60c

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To use SQLite with the Swift Package Manager, add a dependency to your Package.s
1717
```swift
1818
let package = Package(
1919
dependencies: [
20-
.package(url: "https://github.com/shareup/sqlite.git", .upToNextMajor(from: "15.0.0"))
20+
.package(url: "https://github.com/shareup/sqlite.git", .upToNextMajor(from: "16.0.0"))
2121
]
2222
)
2323
```

Sources/SQLite/SQLiteDatabase.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ extension SQLiteDatabase {
123123
} catch let error as SQLiteError {
124124
promise(.failure(error))
125125
} catch {
126-
promise(.failure(.onInternalError(error.localizedDescription)))
126+
promise(.failure(.onInternalError(error as NSError)))
127127
}
128128
}
129129
}
@@ -153,7 +153,7 @@ extension SQLiteDatabase {
153153
if let sqliteError = error as? SQLiteError {
154154
return sqliteError
155155
} else {
156-
return .onInternalError(error.localizedDescription)
156+
return .onInternalError(error as NSError)
157157
}
158158
}
159159
.eraseToAnyPublisher()
@@ -187,7 +187,7 @@ extension SQLiteDatabase {
187187
if let sqliteError = error as? SQLiteError {
188188
return sqliteError
189189
} else {
190-
return .onInternalError(error.localizedDescription)
190+
return .onInternalError(error as NSError)
191191
}
192192
}
193193
.eraseToAnyPublisher()
@@ -510,7 +510,7 @@ extension SQLiteDatabase {
510510
} catch let error as SQLiteError {
511511
promise(.failure(error))
512512
} catch {
513-
promise(.failure(.onInternalError(error.localizedDescription)))
513+
promise(.failure(.onInternalError(error as NSError)))
514514
}
515515
}
516516
}

Sources/SQLite/SQLiteError.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SQLite3
33

44
public enum SQLiteError: Error, Equatable {
55
case databaseIsClosed
6-
case onInternalError(String)
6+
case onInternalError(NSError)
77
case onInvalidPath(String)
88
case onOpenSharedDatabase(String, String)
99
case onOpen(Int32, String)
@@ -106,7 +106,7 @@ extension SQLiteError: CustomStringConvertible {
106106
case .databaseIsClosed:
107107
return "Database is closed"
108108
case .onInternalError(let error):
109-
return "Internal error: '\(error)'"
109+
return "Internal error: '\(String(describing: error))'"
110110
case .onInvalidPath(let path):
111111
return "Invalid path: '\(path)'"
112112
case .onOpenSharedDatabase(let path, let error):

Sources/SQLite/SQLiteResultsPublisher.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ private final class SQLiteStatementResultsSubscription<S>: Subscription, Subscri
185185
state.cancel()
186186
return {
187187
subscription.cancel()
188-
let errorStr = String(describing: error)
189-
sub.receive(completion: .failure(.onInternalError(errorStr)))
188+
sub.receive(completion: .failure(.onInternalError(error as NSError)))
190189
}
191190
}
192191

@@ -252,9 +251,8 @@ private final class SQLiteStatementResultsSubscription<S>: Subscription, Subscri
252251
subscriber = nil
253252
state.cancel()
254253
return {
255-
let err = String(describing: error)
256254
subscription.cancel()
257-
sub.receive(completion: .failure(.onInternalError(err)))
255+
sub.receive(completion: .failure(.onInternalError(error as NSError)))
258256
}
259257
}
260258
}

0 commit comments

Comments
 (0)