-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEBAssert.m
24 lines (17 loc) · 974 Bytes
/
EBAssert.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#import "EBAssert.h"
#import <stdio.h>
void EBAssertHandle(const char *file, uintmax_t line, const char *function, const char *assertion, const char *note, BOOL raiseException)
{
NSMutableString *message = [NSMutableString stringWithFormat: @"=== Assertion failed ===\n Time: %@\n", [[NSDate date] description]];
if (file)
[message appendFormat: @" File: %@:%ju\n", [[NSString stringWithUTF8String: file] lastPathComponent], line];
if (function)
[message appendFormat: @" Function: %@\n", [NSString stringWithUTF8String: function]];
if (assertion)
[message appendFormat: @" Assertion: %@\n", [NSString stringWithUTF8String: assertion]];
if (note)
[message appendFormat: @"\n ### %@\n", [NSString stringWithUTF8String: note]];
fprintf(stderr, "%s", [message UTF8String]);
if (raiseException)
[NSException raise: NSInternalInconsistencyException format: @"%@", message];
}