Fix codecov
THE framework for doing Exceptional Programming in Swift
Exceptional Programming
throws
-> Never {
Functions look like this:
func name(...) throws -> Never { ... }
import XPKit
dependencies: [ .package(url: "https://github.com/ExceptionalProgramming/XP-Swift", from: "1.0.0") ], targets: [ .target( name: "", dependencies: [ "XPKit" ]), ]
Exceptions are a class that should be thrown
class
thrown
Exception
ProgramTerminated
RuntimeException
FatalException
ValueException
All do/catch blocks should rethrow any unhandled exceptions
do/catch
... } catch let error { throw error }
main()
do { try ... } catch _ as ProgramTerminated { } catch let error { throw error }
We understand that not all code is exceptional so we provide get<T>(from:) -> T which will extract the value from the thrown ValueException<T>
get<T>(from:) -> T
ValueException<T>
There is a provided add<T: Addable> function which throws the sum of all values. The Int and UInt families both conform to Addable
add<T: Addable>
Int
UInt
Addable
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
XPKit
THE framework for doing
Exceptional Programming
in SwiftWhat is
Exceptional Programming
throws
)-> Never {
)Functions look like this:
Importing
Exceptions
Exceptions are a
class
that should bethrown
Exception
ProgramTerminated
RuntimeException
FatalException
ValueException
All
do/catch
blocks should rethrow any unhandled exceptionsmain()
Getting values
We understand that not all code is exceptional so we provide
get<T>(from:) -> T
which will extract the value from the thrownValueException<T>
Addition
There is a provided
add<T: Addable>
function whichthrows
the sum of all values. TheInt
andUInt
families both conform toAddable