Add OWSProdExit().

pull/1/head
Matthew Chen 7 years ago
parent 202a91680f
commit 11eaf1474e

@ -139,6 +139,18 @@ NS_ASSUME_NONNULL_BEGIN
} while (NO) } while (NO)
#define OWSProdExit(_messageFormat, ...) \
do { \
OWSFail(_messageFormat, ##__VA_ARGS__); \
exit(0); \
} while (0)
#define OWSCProdExit(_messageFormat, ...) \
do { \
OWSCFail(_messageFormat, ##__VA_ARGS__); \
exit(0); \
} while (NO)
// Avoids Clang analyzer warning: // Avoids Clang analyzer warning:
// Value stored to 'x' during it's initialization is never read // Value stored to 'x' during it's initialization is never read
#define SUPPRESS_DEADSTORE_WARNING(x) \ #define SUPPRESS_DEADSTORE_WARNING(x) \

@ -15,12 +15,6 @@ public func assertOnQueue(_ queue: DispatchQueue) {
} }
} }
public func owsFail(_ message: String) {
Logger.error(message)
Logger.flush()
assertionFailure(message)
}
// Once we're on Swift4.2 we can mark this as inlineable // Once we're on Swift4.2 we can mark this as inlineable
// @inlinable // @inlinable
public func AssertIsOnMainThread(file: String = #file, public func AssertIsOnMainThread(file: String = #file,
@ -32,3 +26,27 @@ public func AssertIsOnMainThread(file: String = #file,
return return
} }
} }
// Once we're on Swift4.2 we can mark this as inlineable
// @inlinable
public func owsFail(_ rawMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) {
// TODO: Format using owsFormatLogMessage() once it is merged.
let message = "\(file) \(function) \(line): \(rawMessage)"
Logger.error(message)
Logger.flush()
assertionFailure(message)
}
// Once we're on Swift4.2 we can mark this as inlineable
// @inlinable
public func owsProdExit(_ rawMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) {
owsFail(rawMessage, file: file, function: function, line: line)
fatalError()
}

Loading…
Cancel
Save