-
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathPluginImportTypes.swift
More file actions
50 lines (44 loc) · 1.48 KB
/
PluginImportTypes.swift
File metadata and controls
50 lines (44 loc) · 1.48 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
//
// PluginImportTypes.swift
// TableProPluginKit
//
import Foundation
public struct PluginImportResult: Sendable {
public let executedStatements: Int
public let executionTime: TimeInterval
public let failedStatement: String?
public let failedLine: Int?
public init(
executedStatements: Int,
executionTime: TimeInterval,
failedStatement: String? = nil,
failedLine: Int? = nil
) {
self.executedStatements = executedStatements
self.executionTime = executionTime
self.failedStatement = failedStatement
self.failedLine = failedLine
}
}
public enum PluginImportError: LocalizedError {
case statementFailed(statement: String, line: Int, underlyingError: any Error)
case rollbackFailed(underlyingError: any Error)
case cancelled
case importFailed(String)
public var errorDescription: String? {
switch self {
case .statementFailed(_, let line, let error):
return "Import failed at line \(line): \(error.localizedDescription)"
case .rollbackFailed(let error):
return "Transaction rollback failed: \(error.localizedDescription)"
case .cancelled:
return "Import cancelled"
case .importFailed(let message):
return "Import failed: \(message)"
}
}
}
public struct PluginImportCancellationError: Error, LocalizedError {
public init() {}
public var errorDescription: String? { "Import cancelled" }
}