forked from vapor/postgres-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostgreSQLError.swift
35 lines (32 loc) · 1.02 KB
/
PostgreSQLError.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Debugging
import COperatingSystem
/// Errors that can be thrown while working with PostgreSQL.
public struct PostgreSQLError: Debuggable {
public static let readableName = "PostgreSQL Error"
public let identifier: String
public var reason: String
public var sourceLocation: SourceLocation
public var stackTrace: [String]
public var possibleCauses: [String]
public var suggestedFixes: [String]
/// Create a new TCP error.
public init(
identifier: String,
reason: String,
possibleCauses: [String] = [],
suggestedFixes: [String] = [],
source: SourceLocation
) {
self.identifier = identifier
self.reason = reason
self.sourceLocation = source
self.stackTrace = PostgreSQLError.makeStackTrace()
self.possibleCauses = possibleCauses
self.suggestedFixes = suggestedFixes
}
}
func VERBOSE(_ string: @autoclosure () -> (String)) {
#if VERBOSE
print("[VERBOSE] [PostgreSQL] \(string())")
#endif
}