Skip to content

Commit

Permalink
fatalError overload w/o string param
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarfland committed Apr 12, 2019
1 parent 129f48f commit 823d486
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,18 @@ public func debugPrint(_ objects: Object?..., separator: String = " ", terminato
return value
}

@noreturn public func fatalError(file: String = #file, line: UInt32 = #line) -> Never {
__throw Exception("Fatal Error, file "+file+", line "+line)
}

@noreturn public func fatalError(_ message: @autoclosure () -> String, file: String = #file, line: UInt32 = #line) -> Never {
if let message = message {
__throw Exception(message()+", file "+file+", line "+line)
} else {
__throw Exception("Fatal Error, file "+file+", line "+line)
}
}

@Conditional("DEBUG") public func precondition(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String, file: String = #file, line: UWord = #line) {
if (!condition()) {
fatalError(message, file: file, line: line)
Expand Down

0 comments on commit 823d486

Please sign in to comment.