Skip to content

Commit f6874c2

Browse files
committed
Move all error codes to an enum
Swift can get at their Ints with .rawValue
1 parent dd3e6a2 commit f6874c2

18 files changed

+50
-48
lines changed

RMQClient.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@
116116
AEADA37E1C71D64A00012D61 /* ControlledInteractionTransport.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEADA37D1C71D64A00012D61 /* ControlledInteractionTransport.swift */; };
117117
AEADA3811C71F59A00012D61 /* RMQMethodMap.h in Headers */ = {isa = PBXBuildFile; fileRef = AEADA37F1C71F59A00012D61 /* RMQMethodMap.h */; settings = {ATTRIBUTES = (Public, ); }; };
118118
AEADA3821C71F59A00012D61 /* RMQMethodMap.m in Sources */ = {isa = PBXBuildFile; fileRef = AEADA3801C71F59A00012D61 /* RMQMethodMap.m */; };
119-
AEB5F15A1CDA4299001C82FF /* RMQConnectionErrors.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB5F1591CDA4299001C82FF /* RMQConnectionErrors.m */; };
120-
AEB5F15C1CDA4360001C82FF /* RMQConnectionErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = AEB5F15B1CDA42A5001C82FF /* RMQConnectionErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
119+
AEB5F15C1CDA4360001C82FF /* RMQErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = AEB5F15B1CDA42A5001C82FF /* RMQErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
120+
AEB5F1601CDA73D6001C82FF /* RMQErrors.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB5F15F1CDA73D6001C82FF /* RMQErrors.m */; };
121121
AEBF7D671CBD197D006EA2E4 /* ChannelCreationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBF7D661CBD197D006EA2E4 /* ChannelCreationTest.swift */; };
122122
AEC4D1D71C74C1AC00D7D585 /* RMQSender.h in Headers */ = {isa = PBXBuildFile; fileRef = AEC4D1D61C74C1AC00D7D585 /* RMQSender.h */; settings = {ATTRIBUTES = (Public, ); }; };
123123
AECDEC9F1CBC0E3600EA6E93 /* RMQConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = AECDEC9E1CBC0E3600EA6E93 /* RMQConnectionDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -305,8 +305,8 @@
305305
AEADA37D1C71D64A00012D61 /* ControlledInteractionTransport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ControlledInteractionTransport.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
306306
AEADA37F1C71F59A00012D61 /* RMQMethodMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RMQMethodMap.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
307307
AEADA3801C71F59A00012D61 /* RMQMethodMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = RMQMethodMap.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
308-
AEB5F1591CDA4299001C82FF /* RMQConnectionErrors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMQConnectionErrors.m; sourceTree = "<group>"; };
309-
AEB5F15B1CDA42A5001C82FF /* RMQConnectionErrors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RMQConnectionErrors.h; sourceTree = "<group>"; };
308+
AEB5F15B1CDA42A5001C82FF /* RMQErrors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RMQErrors.h; sourceTree = "<group>"; };
309+
AEB5F15F1CDA73D6001C82FF /* RMQErrors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMQErrors.m; sourceTree = "<group>"; };
310310
AEBF7D661CBD197D006EA2E4 /* ChannelCreationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChannelCreationTest.swift; sourceTree = "<group>"; };
311311
AEC4D1D61C74C1AC00D7D585 /* RMQSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMQSender.h; sourceTree = "<group>"; };
312312
AECDEC9E1CBC0E3600EA6E93 /* RMQConnectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMQConnectionDelegate.h; sourceTree = "<group>"; };
@@ -443,8 +443,6 @@
443443
AEC4D1D61C74C1AC00D7D585 /* RMQSender.h */,
444444
AEE7FEAB1C3BCD0F00DF8C4F /* RMQConnection.h */,
445445
AEE7FEAC1C3BCD0F00DF8C4F /* RMQConnection.m */,
446-
AEB5F15B1CDA42A5001C82FF /* RMQConnectionErrors.h */,
447-
AEB5F1591CDA4299001C82FF /* RMQConnectionErrors.m */,
448446
AEA45EC91C43D2B900FE1F62 /* RMQTransport.h */,
449447
AEF1E8F41CBE5810000C7AB8 /* RMQTransportDelegate.h */,
450448
AEA45ECF1C43F4DC00FE1F62 /* RMQTCPSocketTransport.h */,
@@ -524,6 +522,8 @@
524522
AEA8A75B1CC979AE00371E38 /* RMQLocalSerialQueue.h */,
525523
AEA8A75D1CC97C1700371E38 /* RMQGCDSerialQueue.h */,
526524
AEA8A75E1CC97C1700371E38 /* RMQGCDSerialQueue.m */,
525+
AEB5F15B1CDA42A5001C82FF /* RMQErrors.h */,
526+
AEB5F15F1CDA73D6001C82FF /* RMQErrors.m */,
527527
AEA8A7751CCA103700371E38 /* Connection */,
528528
AEDBFF271CD8E36F0004DB67 /* TLS */,
529529
AE82798F1C8DBDF80013ADD1 /* Channels */,
@@ -690,7 +690,7 @@
690690
AE9595441CD0EF4A0039418C /* RMQTickingClock.h in Headers */,
691691
AEDBFF231CD8E2E20004DB67 /* RMQPKCS12CertificateConverter.h in Headers */,
692692
AEDBFF301CD8FAF70004DB67 /* RMQTLSOptions.h in Headers */,
693-
AEB5F15C1CDA4360001C82FF /* RMQConnectionErrors.h in Headers */,
693+
AEB5F15C1CDA4360001C82FF /* RMQErrors.h in Headers */,
694694
AEE7FE951C3BCA6000DF8C4F /* RMQClient.h in Headers */,
695695
);
696696
runOnlyForDeploymentPostprocessing = 0;
@@ -896,7 +896,6 @@
896896
AE39BD9F1C68B019000E7A77 /* RMQValues.m in Sources */,
897897
AE898D5C1C3C30D100AA3BF1 /* RMQURI.m in Sources */,
898898
AEE445EC1C7373BF0082132C /* RMQBasicProperties.m in Sources */,
899-
AEB5F15A1CDA4299001C82FF /* RMQConnectionErrors.m in Sources */,
900899
AE82798D1C8DBD6B0013ADD1 /* RMQUnallocatedChannel.m in Sources */,
901900
AE80BAB41C4D47C100E6DFFD /* RMQParser.m in Sources */,
902901
AE95953A1CD0BC1E0039418C /* RMQGCDHeartbeatSender.m in Sources */,
@@ -905,6 +904,7 @@
905904
AE05DA6D1C6A0848009E68C7 /* RMQMessage.m in Sources */,
906905
AE9595451CD0EF4A0039418C /* RMQTickingClock.m in Sources */,
907906
AEF1E8FC1CBEA057000C7AB8 /* RMQHandshaker.m in Sources */,
907+
AEB5F1601CDA73D6001C82FF /* RMQErrors.m in Sources */,
908908
AEA8A76E1CCA0F8300371E38 /* RMQSemaphoreWaiterFactory.m in Sources */,
909909
AEE7FEB61C3BD16200DF8C4F /* RMQQueue.m in Sources */,
910910
AE744E341C85A1B000A4C2FA /* RMQFrame.m in Sources */,

RMQClient/RMQAllocatedChannel.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import "RMQBasicProperties.h"
2-
#import "RMQConstants.h"
2+
#import "RMQErrors.h"
33
#import "RMQFrame.h"
44
#import "RMQMethodDecoder.h"
55
#import "RMQMethodMap.h"

RMQClient/RMQChannel.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
#import "RMQFrameHandler.h"
55
#import "RMQQueue.h"
66

7+
typedef NS_ENUM(NSInteger, RMQChannelError) {
8+
RMQChannelErrorUnallocated = 1,
9+
RMQChannelErrorWaitTimeout,
10+
RMQChannelErrorIncorrectSyncMethod,
11+
RMQChannelErrorQueueNameCollision,
12+
};
13+
714
@protocol RMQConnectionDelegate;
815

916
@protocol RMQChannel <NSObject, RMQFrameHandler>

RMQClient/RMQClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#import <UIKit/UIKit.h>
22
#import <RMQClient/RMQConnection.h>
3-
#import <RMQClient/RMQConnectionErrors.h>
3+
#import <RMQClient/RMQErrors.h>
44
#import <RMQClient/RMQBasicProperties.h>
55
#import <RMQClient/RMQConstants.h>
66
#import <RMQClient/RMQFrame.h>

RMQClient/RMQConnection.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#import "RMQURI.h"
1515
#import "RMQTickingClock.h"
1616
#import "RMQTLSOptions.h"
17-
#import "RMQConnectionErrors.h"
17+
#import "RMQErrors.h"
1818

1919
NSInteger const RMQChannelLimit = 65535;
2020

@@ -206,7 +206,7 @@ - (void)start {
206206

207207
if (handshakeCompletion.timesOut) {
208208
NSError *error = [NSError errorWithDomain:RMQErrorDomain
209-
code:RMQConnectionErrorHandshakeTimedOut
209+
code:RMQErrorConnectionHandshakeTimedOut
210210
userInfo:@{NSLocalizedDescriptionKey: @"Handshake timed out."}];
211211
[self.delegate connection:self failedToConnectWithError:error];
212212
}

RMQClient/RMQConnectionErrors.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

RMQClient/RMQConnectionErrors.m

Lines changed: 0 additions & 5 deletions
This file was deleted.

RMQClient/RMQConstants.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
#import <Foundation/Foundation.h>
22

3-
extern NSString * const RMQErrorDomain;
4-
extern NSString * const RMQClientVersion;
5-
6-
extern NSInteger const RMQChannelErrorUnallocated;
7-
extern NSInteger const RMQChannelErrorWaitTimeout;
8-
extern NSInteger const RMQChannelErrorIncorrectSyncMethod;
9-
extern NSInteger const RMQChannelErrorQueueNameCollision;
3+
extern NSString * const RMQClientVersion;

RMQClient/RMQConstants.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
#import "RMQConstants.h"
2-
NSString * const RMQErrorDomain = @"com.rabbitmq.rabbitmq-objc-client";
3-
NSString * const RMQClientVersion = @"0.0.1";
42

5-
// These aren't in an enum as I haven't figured out how to use an error enum from Swift.
6-
NSInteger const RMQChannelErrorUnallocated = 4;
7-
NSInteger const RMQChannelErrorWaitTimeout = 5;
8-
NSInteger const RMQChannelErrorIncorrectSyncMethod = 6;
9-
NSInteger const RMQChannelErrorQueueNameCollision = 7;
3+
NSString * const RMQClientVersion = @"0.0.1";

RMQClient/RMQErrors.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import <Foundation/Foundation.h>
2+
3+
extern NSString * const RMQErrorDomain;
4+
5+
typedef NS_ENUM(NSInteger, RMQError) {
6+
RMQErrorConnectionHandshakeTimedOut = 1,
7+
RMQErrorTLSCertificateAuthFailure,
8+
RMQErrorTLSCertificateDecodeError,
9+
10+
RMQErrorChannelUnallocated,
11+
RMQErrorChannelWaitTimeout,
12+
RMQErrorChannelIncorrectSyncMethod,
13+
RMQErrorChannelQueueNameCollision,
14+
};

0 commit comments

Comments
 (0)