-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
220 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Created by Helge Heß. | ||
// Copyright © 2022-2023 ZeeZide GmbH. | ||
// | ||
|
||
import struct Foundation.URL | ||
|
||
/** | ||
* An error that is thrown by Lighter database operations. | ||
* | ||
* This carries a higher level error type as well as the SQLite3 | ||
* error code and message. | ||
*/ | ||
public struct LighterError: Swift.Error { | ||
|
||
/// The kind of the error that happened within Lighter. | ||
public enum ErrorType: Hashable { | ||
|
||
case insertFailed(record: AnyHashable) | ||
case updateFailed(record: AnyHashable) | ||
case deleteFailed(record: AnyHashable) | ||
|
||
case couldNotOpenDatabase(URL) | ||
|
||
case couldNotBeginTransaction | ||
case couldNotRollbackTransaction | ||
case couldNotCommitTransaction | ||
|
||
case couldNotFindRelationshipTarget | ||
} | ||
|
||
/// The higher level error type. | ||
public let type : ErrorType | ||
|
||
/// The SQLite3 error code. | ||
public let code : Int32 | ||
/// The SQLite3 error message. | ||
public let message : String? | ||
|
||
@inlinable | ||
public init(_ type: ErrorType, | ||
_ code: Int32, _ message: UnsafePointer<CChar>? = nil) | ||
{ | ||
self.type = type | ||
self.code = code | ||
self.message = message.flatMap(String.init(cString:)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters