mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
[ASDisplayNode] Add support for setting non-fatal error block (#2993)
* Add support for setting non-fatal error block * Better documentation and fix typos * Added ASDisplayNodeAssertNonFatal macro that asserts in dev and call block in prod * Make non fatal error code equals to 1 * Add support for condition in ASDisplayNodeAssertNonFatal * Only call non fatal block if condition isn’t satisfied
This commit is contained in:
committed by
Garrett Moon
parent
f21254593d
commit
b33cced1eb
@@ -59,3 +59,19 @@
|
||||
#define ASDisplayNodeCAssertPositiveReal(description, num) ASDisplayNodeCAssert(num >= 0 && num <= CGFLOAT_MAX, @"%@ must be a real positive integer.", description)
|
||||
#define ASDisplayNodeCAssertInfOrPositiveReal(description, num) ASDisplayNodeCAssert(isinf(num) || (num >= 0 && num <= CGFLOAT_MAX), @"%@ must be infinite or a real positive integer.", description)
|
||||
|
||||
#define ASDisplayNodeErrorDomain @"ASDisplayNodeErrorDomain"
|
||||
#define ASDisplayNodeNonFatalErrorCode 1
|
||||
|
||||
#define ASDisplayNodeAssertNonFatal(condition, desc, ...) \
|
||||
ASDisplayNodeAssert(condition, desc, ##__VA_ARGS__); \
|
||||
if (condition == NO) { \
|
||||
ASDisplayNodeNonFatalErrorBlock block = [ASDisplayNode nonFatalErrorBlock]; \
|
||||
if (block != nil) { \
|
||||
NSDictionary *userInfo = nil; \
|
||||
if (desc.length > 0) { \
|
||||
userInfo = @{ NSLocalizedDescriptionKey : desc }; \
|
||||
} \
|
||||
NSError *error = [NSError errorWithDomain:ASDisplayNodeErrorDomain code:ASDisplayNodeNonFatalErrorCode userInfo:userInfo]; \
|
||||
block(error); \
|
||||
} \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user