Prechádzať zdrojové kódy

Catch exceptions thrown by `[value description]`

Tanner Bennett 8 rokov pred
rodič
commit
a6ad98dd53
1 zmenil súbory, kde vykonal 8 pridanie a 4 odobranie
  1. 8 4
      Classes/Utility/FLEXRuntimeUtility.m

+ 8 - 4
Classes/Utility/FLEXRuntimeUtility.m

@@ -155,10 +155,14 @@ const unsigned int kFLEXNumberOfImplicitArgs = 2;
         }
     }
     
-    if (!description) {
-        // Single line display - replace newlines and tabs with spaces.
-        description = [[value description] stringByReplacingOccurrencesOfString:@"\n" withString:@" "];
-        description = [description stringByReplacingOccurrencesOfString:@"\t" withString:@" "];
+    @try {
+        if (!description) {
+            // Single line display - replace newlines and tabs with spaces.
+            description = [[value description] stringByReplacingOccurrencesOfString:@"\n" withString:@" "];
+            description = [description stringByReplacingOccurrencesOfString:@"\t" withString:@" "];
+        }
+    } @catch (NSException *e) {
+        description = [@"Thrown: " stringByAppendingString:e.reason ?: @"(nil exception reason)"];
     }
     
     if (!description) {