IOSAD-76 NSError+PEP
authorDirk Zimmermann <dirk@pep-project.org>
Tue, 20 Feb 2018 15:38:32 +0100
changeset 483291ca596a013
parent 482 ff364ad63300
child 484 e7b3f52190f1
IOSAD-76 NSError+PEP
pEpObjCAdapter.xcodeproj/project.pbxproj
pEpObjCAdapter/NSError+PEP.h
pEpObjCAdapter/NSError+PEP.m
     1.1 --- a/pEpObjCAdapter.xcodeproj/project.pbxproj	Tue Feb 20 15:38:31 2018 +0100
     1.2 +++ b/pEpObjCAdapter.xcodeproj/project.pbxproj	Tue Feb 20 15:38:32 2018 +0100
     1.3 @@ -34,6 +34,7 @@
     1.4  		435796E31FB5E51A00395A9E /* PEPMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 435796E21FB5E51A00395A9E /* PEPMessage.m */; };
     1.5  		43676B661C57EA1A00233933 /* B623F674_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43676B641C57EA1A00233933 /* B623F674_sec.asc */; };
     1.6  		43D27DE61F5DA7B700795687 /* NSDictionary+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 43D27DE51F5DA7B700795687 /* NSDictionary+Extension.m */; };
     1.7 +		43DED786203C25E200D45CD6 /* NSError+PEP.m in Sources */ = {isa = PBXBuildFile; fileRef = 43DED785203C25E200D45CD6 /* NSError+PEP.m */; };
     1.8  		43E02A201C71F65B008F05E9 /* A3FC7F0A_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1C1C71F65B008F05E9 /* A3FC7F0A_sec.asc */; };
     1.9  		43E02A211C71F65B008F05E9 /* A3FC7F0A.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1D1C71F65B008F05E9 /* A3FC7F0A.asc */; };
    1.10  		43E02A221C71F65B008F05E9 /* account_A3FC7F0A.ser in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1E1C71F65B008F05E9 /* account_A3FC7F0A.ser */; };
    1.11 @@ -161,6 +162,8 @@
    1.12  		43676B641C57EA1A00233933 /* B623F674_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = B623F674_sec.asc; sourceTree = "<group>"; };
    1.13  		43D27DE41F5DA78700795687 /* NSDictionary+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+Extension.h"; sourceTree = "<group>"; };
    1.14  		43D27DE51F5DA7B700795687 /* NSDictionary+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+Extension.m"; sourceTree = "<group>"; };
    1.15 +		43DED784203C25E200D45CD6 /* NSError+PEP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSError+PEP.h"; sourceTree = "<group>"; };
    1.16 +		43DED785203C25E200D45CD6 /* NSError+PEP.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSError+PEP.m"; sourceTree = "<group>"; };
    1.17  		43E02A1C1C71F65B008F05E9 /* A3FC7F0A_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = A3FC7F0A_sec.asc; sourceTree = "<group>"; };
    1.18  		43E02A1D1C71F65B008F05E9 /* A3FC7F0A.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = A3FC7F0A.asc; sourceTree = "<group>"; };
    1.19  		43E02A1E1C71F65B008F05E9 /* account_A3FC7F0A.ser */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = account_A3FC7F0A.ser; sourceTree = "<group>"; };
    1.20 @@ -295,6 +298,8 @@
    1.21  				433E28901FA741DE00E359B3 /* PEPIdentity.m */,
    1.22  				435796E11FB5E51A00395A9E /* PEPMessage.h */,
    1.23  				435796E21FB5E51A00395A9E /* PEPMessage.m */,
    1.24 +				43DED784203C25E200D45CD6 /* NSError+PEP.h */,
    1.25 +				43DED785203C25E200D45CD6 /* NSError+PEP.m */,
    1.26  			);
    1.27  			path = pEpObjCAdapter;
    1.28  			sourceTree = "<group>";
    1.29 @@ -461,6 +466,7 @@
    1.30  				1508AEAF1F8792AC001D5230 /* PEPCopyableThread.m in Sources */,
    1.31  				15206CAA1F8BA183003FF880 /* PEPSessionProvider.m in Sources */,
    1.32  				43209B411ECC2DB8007E7E2E /* PEPObjCAdapter.m in Sources */,
    1.33 +				43DED786203C25E200D45CD6 /* NSError+PEP.m in Sources */,
    1.34  				433E28911FA741DE00E359B3 /* PEPIdentity.m in Sources */,
    1.35  				43D27DE61F5DA7B700795687 /* NSDictionary+Extension.m in Sources */,
    1.36  				435796E31FB5E51A00395A9E /* PEPMessage.m in Sources */,
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pEpObjCAdapter/NSError+PEP.h	Tue Feb 20 15:38:32 2018 +0100
     2.3 @@ -0,0 +1,23 @@
     2.4 +//
     2.5 +//  NSError+PEP.h
     2.6 +//  pEpObjCAdapter
     2.7 +//
     2.8 +//  Created by Dirk Zimmermann on 20.02.18.
     2.9 +//  Copyright © 2018 p≡p. All rights reserved.
    2.10 +//
    2.11 +
    2.12 +#import <Foundation/Foundation.h>
    2.13 +
    2.14 +#import "pEpEngine.h"
    2.15 +
    2.16 +/**
    2.17 + Extension for creating `NSError`s from `PEP_STATUS`
    2.18 + */
    2.19 +@interface NSError (Extension)
    2.20 +
    2.21 ++ (NSError *)errorWithPEPStatus:(PEP_STATUS)status
    2.22 +                       userInfo:(NSDictionary<NSErrorUserInfoKey, id> *)dict;
    2.23 +
    2.24 ++ (NSError *)errorWithPEPStatus:(PEP_STATUS)status;
    2.25 +
    2.26 +@end
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pEpObjCAdapter/NSError+PEP.m	Tue Feb 20 15:38:32 2018 +0100
     3.3 @@ -0,0 +1,27 @@
     3.4 +//
     3.5 +//  NSError+PEP.m
     3.6 +//  pEpObjCAdapter
     3.7 +//
     3.8 +//  Created by Dirk Zimmermann on 20.02.18.
     3.9 +//  Copyright © 2018 p≡p. All rights reserved.
    3.10 +//
    3.11 +
    3.12 +#import "NSError+PEP.h"
    3.13 +
    3.14 +@implementation NSError (Extension)
    3.15 +
    3.16 ++ (NSError *)errorWithPEPStatus:(PEP_STATUS)status
    3.17 +                       userInfo:(NSDictionary<NSErrorUserInfoKey, id> *)dict
    3.18 +{
    3.19 +    if (status != PEP_STATUS_OK) {
    3.20 +        return [NSError errorWithDomain:@"pEp" code:status userInfo:dict];
    3.21 +    }
    3.22 +    return nil;
    3.23 +}
    3.24 +
    3.25 ++ (NSError *)errorWithPEPStatus:(PEP_STATUS)status
    3.26 +{
    3.27 +    return [self errorWithPEPStatus:status userInfo:nil];
    3.28 +}
    3.29 +
    3.30 +@end