]> granicus.if.org Git - handbrake/commitdiff
MacGui: add a method to send a NSError to activity log.
authorDamiano Galassi <damiog@gmail.com>
Thu, 15 Aug 2019 05:37:38 +0000 (07:37 +0200)
committerDamiano Galassi <damiog@gmail.com>
Thu, 15 Aug 2019 05:37:38 +0000 (07:37 +0200)
macosx/HBUtilities.h
macosx/HBUtilities.m

index 18f294a01800fdd3974f76e5553a321d993652fb..892b4f18296f31b7f8fd6b39b954955214fbe727 100644 (file)
@@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
  *  @param format a standard c format string with varargs.
  */
 + (void)writeToActivityLog:(const char *)format, ...;
++ (void)writeErrorToActivityLog:(NSError *)error;
 + (void)writeToActivityLogWithNoHeader:(NSString *)text;
 
 + (nullable NSURL *)URLFromBookmark:(NSData *)bookmark;
index 733226e8903749a4ce39a11c46455d33e4c1ea9e..000f0cbccbcadbac71f34c507edfe86a33a17a67 100644 (file)
@@ -13,7 +13,7 @@
 
 + (NSString *)handBrakeVersion
 {
-    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
+    NSDictionary *infoDictionary = NSBundle.mainBundle.infoDictionary;
     return [NSString stringWithFormat:@"Handbrake Version: %@ (%@)",
             infoDictionary[@"CFBundleShortVersionString"],
             infoDictionary[@"CFBundleVersion"]];
     va_end(args);
 }
 
++ (void)writeErrorToActivityLog:(NSError *)error
+{
+    [self writeToActivityLog:"Error domain: %s", error.domain.UTF8String];
+    [self writeToActivityLog:"Error code: %d", error.code];
+    if (error.localizedDescription)
+    {
+        [self writeToActivityLog:"Error description: %s", error.localizedDescription.UTF8String];
+    }
+    if (error.debugDescription)
+    {
+        [self writeToActivityLog:"Error debug description: %s", error.debugDescription.UTF8String];
+    }
+}
+
 + (void)writeToActivityLogWithNoHeader:(NSString *)text
 {
     fprintf(stderr, "%s", text.UTF8String);
@@ -70,8 +84,7 @@
 
     if (error)
     {
-        NSString *error_message = [NSString stringWithFormat:@"Failed to resolved bookmark: %@", error];
-        [HBUtilities writeToActivityLog:"%s", error_message.UTF8String];
+        [HBUtilities writeErrorToActivityLog:error];
     }
 
     return isStale ? nil : url;