Error Handling
-
A closure which is called when Orion encounters a non-recoverable error.
Important
The closure must terminate the program, as implied by the
Neverreturn value.Declaration
Swift
public typealias OrionErrorHandler = ( _ message: @autoclosure () -> String, _ file: StaticString, _ line: UInt ) -> NeverParameters
messageThe error message.
fileThe file associated with the error.
lineThe line number associated with the error.
-
Updates the
OrionErrorHandlerwhich is called when Orion encounters a non-recoverable error.The default error handler is
fatalError.Warning
This function is thread-safe but not reentrant. Do not call
updateOrionErrorHandler(_:)ororionError(_:file:line:)inside theupdateblock or the returned error handler.Example
updateOrionErrorHandler { old in return { message, file, line in let str = message() // do something with str, file, line old(str, file, line) } }Declaration
Swift
public func updateOrionErrorHandler( _ update: (_ previous: @escaping OrionErrorHandler) -> OrionErrorHandler )Parameters
updateA closure which is passed the previous error handler and returns an updated handler.
previousThe previous error handler. You may want to call this at the end of your error handler closure.
-
Raises an unrecoverable error within an Orion-related subsystem, and stops execution. Do not call this outside Orion code.
The default behavior is to forward all arguments to
fatalError. This behavior can be modified usingupdateOrionErrorHandler(_:).Warning
This function is thread-safe but not reentrant. Do not call
orionError(_:file:line:)orupdateOrionErrorHandler(_:)inside themessageautoclosure.Declaration
Swift
public func orionError( _ message: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line ) -> NeverParameters
messageThe error message.
fileThe file name associated with the error. Defaults to the file in which
orionError(_:file:line:)was called.lineThe line number associated with the error. Defaults to the line number on which
orionError(_:file:line:)was called.
View on GitHub
Install in Dash
Error Handling Reference