forked from vapor/postgres-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostgreSQLError.swift
38 lines (36 loc) · 1.16 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
36
37
38
import Debugging
import COperatingSystem
/// Errors that can be thrown while working with PostgreSQL.
public struct PostgreSQLError: Traceable, Debuggable, Helpable, Swift.Error, Encodable {
public static let readableName = "PostgreSQL Error"
public let identifier: String
public var reason: String
public var file: String
public var function: String
public var line: UInt
public var column: UInt
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] = [],
file: String = #file,
function: String = #function,
line: UInt = #line,
column: UInt = #column
) {
self.identifier = identifier
self.reason = reason
self.file = file
self.function = function
self.line = line
self.column = column
self.stackTrace = PostgreSQLError.makeStackTrace()
self.possibleCauses = possibleCauses
self.suggestedFixes = suggestedFixes
}
}