mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
SQLiteError adopts CustomStringConvertible
This commit is contained in:
1 parent
adbe09d6d3
commit
4e8b69007b
2 files changed
+20
-14
No files matched your search
+1
-14
@@ -137,20 +137,7 @@ func failOnError<Result>(@noescape block: (Void) throws -> Result) -> Result {
|
||||
do {
|
||||
return try block()
|
||||
} catch let error as SQLiteError {
|
||||
// How to write this with a switch?
|
||||
if let sql = error.sql {
|
||||
if let message = error.message {
|
||||
fatalError("SQLite error \(error.code) with statement `\(sql)`: \(message)")
|
||||
} else {
|
||||
fatalError("SQLite error \(error.code) with statement `\(sql)`")
|
||||
}
|
||||
} else {
|
||||
if let message = error.message {
|
||||
fatalError("SQLite error \(error.code): \(message)")
|
||||
} else {
|
||||
fatalError("SQLite error \(error.code)")
|
||||
}
|
||||
}
|
||||
fatalError(error.description)
|
||||
} catch {
|
||||
fatalError("error: \(error)")
|
||||
}
|
||||
|
||||
@@ -41,6 +41,25 @@ public struct SQLiteError : ErrorType {
|
||||
}
|
||||
}
|
||||
|
||||
extension SQLiteError: CustomStringConvertible {
|
||||
public var description: String {
|
||||
// How to write this with a switch?
|
||||
if let sql = sql {
|
||||
if let message = message {
|
||||
fatalError("SQLite error \(code) with statement `\(sql)`: \(message)")
|
||||
} else {
|
||||
fatalError("SQLite error \(code) with statement `\(sql)`")
|
||||
}
|
||||
} else {
|
||||
if let message = message {
|
||||
fatalError("SQLite error \(code): \(message)")
|
||||
} else {
|
||||
fatalError("SQLite error \(code)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum SQLiteValue {
|
||||
case Null
|
||||
case Integer(Int64)
|
||||
|
||||
Reference in new issue
Block a user