mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-19 16:21:15 +01:00
importing unit tests
This commit is contained in:
@@ -70,4 +70,16 @@ public extension CoreStore {
|
||||
functionName: functionName
|
||||
)
|
||||
}
|
||||
|
||||
@noreturn
|
||||
internal static func abort(message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
|
||||
|
||||
self.logger.abort(
|
||||
message,
|
||||
fileName: fileName,
|
||||
lineNumber: lineNumber,
|
||||
functionName: functionName
|
||||
)
|
||||
Swift.fatalError(message, file: fileName, line: UInt(lineNumber))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,17 @@ public protocol CoreStoreLogger {
|
||||
*/
|
||||
func assert(@autoclosure condition: () -> Bool, @autoclosure message: () -> String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
|
||||
|
||||
/**
|
||||
Handles fatal errors made throughout the `CoreStore` framework. The app wil terminate after this method is called.
|
||||
- Important: Implementers may guarantee that the function doesn't return, either by calling another `@noreturn` function such as `fatalError()` or `abort()`, or by raising an exception. If the implementation does not terminate the app, CoreStore will call an internal `fatalError()` to do so.
|
||||
|
||||
- parameter message: the fatal error message
|
||||
- parameter fileName: the source file name
|
||||
- parameter lineNumber: the source line number
|
||||
- parameter functionName: the source function name
|
||||
*/
|
||||
func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString)
|
||||
|
||||
|
||||
// MARK: Deprecated
|
||||
|
||||
@@ -100,4 +111,9 @@ extension CoreStoreLogger {
|
||||
|
||||
self.log(error: error.bridgeToSwift, message: message, fileName: fileName, lineNumber: lineNumber, functionName: functionName)
|
||||
}
|
||||
|
||||
public func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
|
||||
|
||||
Swift.fatalError(message, file: fileName, line: UInt(lineNumber))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,22 @@ public final class DefaultLogger: CoreStoreLogger {
|
||||
return
|
||||
}
|
||||
Swift.print("❗ [CoreStore: Assertion Failure] \((fileName.stringValue as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
|
||||
Swift.fatalError()
|
||||
Swift.fatalError(file: fileName, line: UInt(lineNumber))
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Handles fatal errors made throughout the `CoreStore` framework.
|
||||
- Important: This method should be marked `@noreturn` and implementers should guarantee that the function doesn't, either by calling another `@noreturn` function such as `fatalError()` or `abort()`, or by raising an exception.
|
||||
|
||||
- parameter message: the fatal error message
|
||||
- parameter fileName: the source file name
|
||||
- parameter lineNumber: the source line number
|
||||
- parameter functionName: the source function name
|
||||
*/
|
||||
public func abort(message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
|
||||
|
||||
Swift.print("❗ [CoreStore: Fatal Error] \((fileName.stringValue as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
|
||||
Swift.fatalError(file: fileName, line: UInt(lineNumber))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user