Fatal

public enum Fatal

An umbrella type supplying static members to handle common and conventional exit scenarios.

  • Declaration

    Swift

    @discardableResult
    public static func preconditionFailure<T>(_ message: @autoclosure () -> String = String(),
                                              file: StaticString = #file,
                                              line: UInt = #line) -> T
  • Die because a default method must be overriden by a subtype or extension.

    Declaration

    Swift

    public static func mustOverride(function: StaticString = #function,
                                    file: StaticString = #file,
                                    line: UInt = #line) -> Never
  • Die because this code branch should be unreachable

    Declaration

    Swift

    public static func unreachable(_ why: String, file: StaticString = #file, line: UInt = #line) -> Never
  • Die because this method or function has not yet been implemented.

    Note

    This name takes precedence over unimplemented as it is clearer and more Swifty

    Declaration

    Swift

    public static func notImplemented(_ why: String? = nil, file: StaticString = #file, line: UInt = #line) -> Never
  • Die because of a failed assertion. This does not distinguish between logic conditions (as in assert) and user calling requirements (as in precondition)

    Declaration

    Swift

    public static func require(_ why: String? = nil, file: StaticString = #file, line: UInt = #line) -> Never
  • Die because this TO DO item has not yet been implemented.

    Declaration

    Swift

    public static func TODO(_ reason: String? = nil, file: StaticString = #file, line: UInt = #line) -> Never
  • Provide a Fatal.error equivalent to fatalError() to move Swift standard style away from using fatalError directly

    Declaration

    Swift

    public static func error(_ reason: String? = nil, file: StaticString = #file, line: UInt = #line) -> Never