Skip to content

Commit

Permalink
Wrote a function to assign errors nicely. Not overly happy with this …
Browse files Browse the repository at this point in the history
…but it needs to be available to multiple classes.
  • Loading branch information
Danny Greg committed Aug 24, 2010
1 parent 14347f8 commit 0df633b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion objc/CFobError.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ enum _CFobErrorCode {
CFobErrorCodeCouldNotDecode = -2,
CFobErrorCodeSigningFailed = -3,
CFobErrorCodeCouldNotEncode = -4,
CFobErrorCodeInvalidKey = -5
};

void CFobAssignErrorWithDescriptionAndCode(NSError **err, NSString *description, NSInteger code);
18 changes: 18 additions & 0 deletions objc/CFobError.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// CFobError.h
// cocoafob
//
// Created by Danny Greg on 24/08/2010.
// Copyright 2010 Realmac Software. All rights reserved.
// Licensed under CC Attribution Licence 3.0 <http://creativecommons.org/licenses/by/3.0/>
//

#import "CFobError.h"

#import "CFobLicVerifier.h"

void CFobAssignErrorWithDescriptionAndCode(NSError **err, NSString *description, NSInteger code)
{
if (err != NULL)
*err = [NSError errorWithDomain:[[NSBundle bundleForClass:[CFobLicVerifier class]] bundleIdentifier] code:code userInfo:[NSDictionary dictionaryWithObject:NSLocalizedStringFromTableInBundle(description, nil, [NSBundle bundleForClass:[CFobLicVerifier class]], nil) forKey:NSLocalizedDescriptionKey]];
}
8 changes: 8 additions & 0 deletions objc/cocoafob.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
3035258E1223C01100AACD22 /* NSString+PECrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = C7E3784D0F59DB15002061CD /* NSString+PECrypt.h */; };
3035258F1223C01100AACD22 /* NSString-Base64Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = C7A731670F5F42D500D40AFE /* NSString-Base64Extensions.h */; };
303525A81223C19D00AACD22 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 303524D01223BE4D00AACD22 /* libcrypto.dylib */; };
303526851223D4DA00AACD22 /* CFobError.h in Headers */ = {isa = PBXBuildFile; fileRef = 303526831223D4DA00AACD22 /* CFobError.h */; };
303526981223DC9600AACD22 /* CFobError.m in Sources */ = {isa = PBXBuildFile; fileRef = 303526971223DC9600AACD22 /* CFobError.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -32,6 +34,8 @@
303524091223BB9600AACD22 /* CocoaFob-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CocoaFob-Info.plist"; sourceTree = "<group>"; };
303524D01223BE4D00AACD22 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = usr/lib/libcrypto.dylib; sourceTree = SDKROOT; };
303524D61223BE6700AACD22 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
303526831223D4DA00AACD22 /* CFobError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFobError.h; sourceTree = "<group>"; };
303526971223DC9600AACD22 /* CFobError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CFobError.m; sourceTree = "<group>"; };
32A70AAB03705E1F00C91783 /* cocoafob_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocoafob_Prefix.pch; sourceTree = "<group>"; };
C6859EA3029092ED04C91782 /* cocoafob.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = cocoafob.1; sourceTree = "<group>"; };
C7A731670F5F42D500D40AFE /* NSString-Base64Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString-Base64Extensions.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -87,6 +91,8 @@
C7E3784A0F59DB15002061CD /* CFobLicVerifier.m */,
32A70AAB03705E1F00C91783 /* cocoafob_Prefix.pch */,
08FB7796FE84155DC02AAC07 /* cocoafob.m */,
303526831223D4DA00AACD22 /* CFobError.h */,
303526971223DC9600AACD22 /* CFobError.m */,
);
name = Source;
sourceTree = "<group>";
Expand Down Expand Up @@ -169,6 +175,7 @@
303525891223BFFF00AACD22 /* encoder.h in Headers */,
303524231223BCB500AACD22 /* CFobLicVerifier.h in Headers */,
303524241223BCBA00AACD22 /* CFobLicGenerator.h in Headers */,
303526851223D4DA00AACD22 /* CFobError.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -233,6 +240,7 @@
303524141223BC2200AACD22 /* NSData+PECrypt.m in Sources */,
303524151223BC2200AACD22 /* NSString+PECrypt.m in Sources */,
303524161223BC2200AACD22 /* NSString-Base64Extensions.m in Sources */,
303526981223DC9600AACD22 /* CFobError.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 0df633b

Please sign in to comment.