Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  ErrorHandler.m  Sprache: unbekannt

 
Spracherkennung für: .m vermutete Sprache: Lisp {Lisp[62] ABAP[39] Masm[31]} [Methode: maximale Elemente, drei Dimensionen]

#import "ErrorHandler.h"
#import "ThreemaFramework/ThreemaFramework-Swift.h"

#ifdef DEBUG
  static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
#else
  static const DDLogLevel ddLogLevel = DDLogLevelWarning;
#endif
@interface ErrorHandler ()

@end

static ErrorHandler *errorHandler;

@implementation ErrorHandler

+ (instancetype)errorHandler {
    return [[ErrorHandler alloc] init];
}

+ (void)abortWithError:(nonnull NSError *)error {
    // Could called from background thread, since we have Core Data child context
    dispatch_async(dispatch_get_main_queue(), ^{
        [self abortWithError:error additionalText:nil];
    });
}

+ (void)abortWithError:(nonnull NSError *)error additionalText:(nullable NSString *)additionalText {
    DDLogError(@"Aborting: unresolved error %@, %@", error, [error userInfo]);

    // Get first description, because localizedDescription on Swift enum Error cannot be overriden
    NSString *description = [error description];
    if (description == nil) {
        description = [error localizedDescription];
    }

    NSString *localizedMessage = [NSString stringWithFormat:@"%@ (%@ %ld)", description, error.domain, (long)error.code];

    if (additionalText != nil) {
        localizedMessage = [NSString stringWithFormat:@"%@\n\n%@", localizedMessage, additionalText];
    }
    
    [ErrorHandler abortWithTitle:[BundleUtil localizedStringForKey:@"error_abort"] message:localizedMessage];
}

+ (void)abortWithTitle:(nonnull NSString *)title message:(nonnull NSString *)message {
    errorHandler = [ErrorHandler errorHandler];
    
    Class UIApplicationClass = NSClassFromString(@"UIApplication");
    if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) {
        return;
    }
    
    UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
    if (application == nil) {
        return;
    } else if (application.windows.firstObject.rootViewController == nil) {
        UIViewController *dummyViewController = [[UIViewController alloc] init];
        application.windows.firstObject.rootViewController = dummyViewController;
    }
    
    [UIAlertTemplate showOKAlertWithOwner:application.windows.firstObject.rootViewController title:title message:message actionOk:^(UIAlertAction * _Nonnull action) {
        exit(0);
    }];
}

@end

[Dauer der Verarbeitung: 0.11 Sekunden]

                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104842
#Domains=499167