From c324286fb78834d38b50b9caa2bfa0b1fa05bf3e Mon Sep 17 00:00:00 2001 From: Martin Kralik Date: Tue, 24 Nov 2015 06:28:08 -0800 Subject: [PATCH] truncate redbox error Summary: If a redbox error is too long it's not shown at all: {F24443416} This diff truncates it to its first 10000 chars, which should be good enough: {F24443417} The reason is a limitation of UILabel which backs text property on the used UITableViewCell. Ideally we would use a custom cell with UITextView, but I don't feel there is any value in displaying super long error messages in a redbox. public Reviewed By: jspahrsummers, nicklockwood Differential Revision: D2690638 fb-gh-sync-id: d9b3fcecd2602e8c2618afe1bb97221c2e506605 --- React/Modules/RCTRedBox.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/Modules/RCTRedBox.m b/React/Modules/RCTRedBox.m index a334c7533..9f603afd0 100644 --- a/React/Modules/RCTRedBox.m +++ b/React/Modules/RCTRedBox.m @@ -107,7 +107,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) { if ((self.hidden && shouldShow) || (!self.hidden && [_lastErrorMessage isEqualToString:message])) { _lastStackTrace = stack; - _lastErrorMessage = message; + // message is displayed using UILabel, which is unable to render text of unlimited length, so we truncate it + _lastErrorMessage = [message substringToIndex:MIN(10000, message.length)]; [_stackTraceTableView reloadData];