1111
1212#import " RCTDefines.h"
1313
14- /* *
15- * The default error domain to be used for React errors.
16- */
17- RCT_EXTERN NSString *const RCTErrorDomain;
18-
19- /* *
20- * A block signature to be used for custom assertion handling.
21- */
22- typedef void (^RCTAssertFunction)(
23- NSString *condition,
24- NSString *fileName,
25- NSNumber *lineNumber,
26- NSString *function,
27- NSString *message
28- );
29-
3014/* *
3115 * This is the main assert macro that you should use. Asserts should be compiled out
32- * in production builds
16+ * in production builds. You can customize the assert behaviour by setting a custom
17+ * assert handler through `RCTSetAssertFunction`.
3318 */
3419#ifndef NS_BLOCK_ASSERTIONS
3520#define RCTAssert (condition, ...) do { \
@@ -48,21 +33,50 @@ RCT_EXTERN void _RCTAssertFormat(
4833 const char *, const char *, int , const char *, NSString *, ...
4934) NS_FORMAT_FUNCTION(5 ,6 );
5035
36+ /* *
37+ * Report a fatal condition when executing. These calls will _NOT_ be compiled out
38+ * in production, and crash the app by default. You can customize the fatal behaviour
39+ * by setting a custom fatal handler through `RCTSetFatalHandler`.
40+ */
41+ RCT_EXTERN void RCTFatal (NSError *error);
42+
43+ /* *
44+ * The default error domain to be used for React errors.
45+ */
46+ RCT_EXTERN NSString *const RCTErrorDomain;
47+
48+ /* *
49+ * JS Stack trace provided as part of an NSError's userInfo
50+ */
51+ RCT_EXTERN NSString *const RCTJSStackTraceKey;
52+
53+ /* *
54+ * A block signature to be used for custom assertion handling.
55+ */
56+ typedef void (^RCTAssertFunction)(
57+ NSString *condition,
58+ NSString *fileName,
59+ NSNumber *lineNumber,
60+ NSString *function,
61+ NSString *message
62+ );
63+
64+ typedef void (^RCTFatalHandler)(NSError *error);
65+
5166/* *
5267 * Convenience macro for asserting that a parameter is non-nil/non-zero.
5368 */
54- #define RCTAssertParam (name ) RCTAssert(name, \
55- @" '%s ' is a required parameter" , #name)
69+ #define RCTAssertParam (name ) RCTAssert(name, @" '%s ' is a required parameter" , #name)
5670
5771/* *
5872 * Convenience macro for asserting that we're running on main thread.
5973 */
6074#define RCTAssertMainThread () RCTAssert([NSThread isMainThread ], \
61- @" This function must be called on the main thread" )
75+ @" This function must be called on the main thread" )
6276
6377/* *
6478 * These methods get and set the current assert function called by the RCTAssert
65- * macros. You can use these to replace the standard behavior with custom log
79+ * macros. You can use these to replace the standard behavior with custom assert
6680 * functionality.
6781 */
6882RCT_EXTERN void RCTSetAssertFunction (RCTAssertFunction assertFunction);
@@ -82,6 +96,12 @@ RCT_EXTERN void RCTAddAssertFunction(RCTAssertFunction assertFunction);
8296 */
8397RCT_EXTERN void RCTPerformBlockWithAssertFunction (void (^block)(void ), RCTAssertFunction assertFunction);
8498
99+ /* *
100+ These methods get and set the current fatal handler called by the RCTFatal method.
101+ */
102+ RCT_EXTERN void RCTSetFatalHandler (RCTFatalHandler fatalHandler);
103+ RCT_EXTERN RCTFatalHandler RCTGetFatalHandler (void );
104+
85105/* *
86106 * Get the current thread's name (or the current queue, if in debug mode)
87107 */
@@ -106,6 +126,6 @@ _Pragma("clang diagnostic pop")
106126
107127#else
108128
109- #define RCTAssertThread (thread, format... )
129+ #define RCTAssertThread (thread, format... ) do { } while ( 0 )
110130
111131#endif
0 commit comments