Merge branch 'charlesmchen/swiftExit'

pull/1/head
Matthew Chen 7 years ago
commit 64007e7d71

@ -240,8 +240,7 @@ static NSTimeInterval launchStartedAt;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[UIApplication.sharedApplication setApplicationIconBadgeNumber:1];
[DDLog flushLog];
exit(0);
OWSFail(@"!isDatabasePasswordAccessible.");
}
}
@ -339,9 +338,7 @@ static NSTimeInterval launchStartedAt;
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[Pastelog submitLogsWithCompletion:^{
OWSLogInfo(@"exiting after sharing debug logs.");
[DDLog flushLog];
exit(0);
OWSFail(@"exiting after sharing debug logs.");
}];
}]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];

@ -233,7 +233,7 @@ NS_ASSUME_NONNULL_BEGIN
[self clearAllNotifications];
[DebugLogger.sharedLogger wipeLogs];
exit(0);
OWSFail(@"App data reset.");
}
+ (void)clearAllNotifications

@ -69,8 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
UIAlertAction *quitAction = [UIAlertAction actionWithTitle:@"Quit"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[DDLog flushLog];
exit(0);
OWSFail(@"Obsolete install.");
}];
[alertController addAction:quitAction];

@ -153,17 +153,22 @@ NS_ASSUME_NONNULL_BEGIN
OWSCFailWithoutLogging(_messageFormat, ##__VA_ARGS__); \
} while (NO)
void SwiftExit(NSString *message, const char *file, const char *function, int line);
#define OWSFail(_messageFormat, ...) \
do { \
OWSFailDebug(_messageFormat, ##__VA_ARGS__); \
exit(0); \
\
NSString *_message = [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]; \
SwiftExit(_message, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while (0)
#define OWSCFail(_messageFormat, ...) \
do { \
OWSCFailDebug(_messageFormat, ##__VA_ARGS__); \
exit(0); \
\
NSString *_message = [NSString stringWithFormat:_messageFormat, ##__VA_ARGS__]; \
SwiftExit(_message, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while (NO)
// Avoids Clang analyzer warning:

@ -3,7 +3,15 @@
//
#import "OWSAsserts.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
void SwiftExit(NSString *message, const char *file, const char *function, int line)
{
NSString *_file = [NSString stringWithFormat:@"%s", file];
NSString *_function = [NSString stringWithFormat:@"%s", function];
[OWSSwiftUtils owsFail:message file:_file function:_function line:line];
}
NS_ASSUME_NONNULL_END

@ -43,7 +43,7 @@ public func owsFail(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) -> Never {
owsFailDebug(logMessage, file: file, function: function, line: line)
let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line)
fatalError(formattedMessage)
@ -56,4 +56,16 @@ public func notImplemented(file: String = #file,
line: Int = #line) -> Never {
owsFail("Method not implemented.", file: file, function: function, line: line)
}
@objc public class OWSSwiftUtils: NSObject {
// This method can be invoked from Obj-C to exit the app.
@objc public class func owsFail(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) -> Never {
owsFailDebug(logMessage, file: file, function: function, line: line)
let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line)
fatalError(formattedMessage)
}
}

Loading…
Cancel
Save