Skip to content

Commit 17b974f

Browse files
authored
Merge pull request ZapicInc#29 from dsarfati/error-codes
iOS - Zapic error codes
2 parents 3ed8301 + a4349cf commit 17b974f

File tree

6 files changed

+82
-5
lines changed

6 files changed

+82
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import <Foundation/Foundation.h>
2+
3+
FOUNDATION_EXPORT NSInteger const ZPCFailedToStartError;
4+
FOUNDATION_EXPORT NSInteger const ZPCInvalidResponseError;
5+
FOUNDATION_EXPORT NSInteger const ZPCVersionNotSupportedError;
6+
FOUNDATION_EXPORT NSInteger const ZPCInvalidQueryError;
7+
FOUNDATION_EXPORT NSInteger const ZPCNetworkError;
8+
FOUNDATION_EXPORT NSInteger const ZPCLoginRequiredError;

Assets/Plugins/iOS/Zapic/Controllers/ZPCErrors.h.meta

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import "ZPCErrors.h"
2+
3+
NSInteger const ZPCFailedToStartError = 2600;
4+
NSInteger const ZPCInvalidResponseError = 2601;
5+
NSInteger const ZPCVersionNotSupportedError = 2650;
6+
NSInteger const ZPCInvalidQueryError = 2651;
7+
NSInteger const ZPCNetworkError = 2652;
8+
NSInteger const ZPCLoginRequiredError = 2653;

Assets/Plugins/iOS/Zapic/Controllers/ZPCErrors.m.meta

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/iOS/Zapic/Controllers/ZPCQueryManager.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "ZPCQueryManager.h"
2+
#import "ZPCErrors.h"
23
#import "ZPCLog.h"
34

45
typedef void (^ResponseBlock)(id response, NSError *error);
@@ -17,7 +18,6 @@ @implementation ZPCQueryManager
1718
static NSString *const PlayerQuery = @"player";
1819

1920
static NSString *const ZPCErrorDomain = @"com.Zapic";
20-
static NSInteger const ZPCErrorUnavailable = 2600;
2121

2222
- (void)setIsReady:(BOOL)isReady {
2323
if (isReady == _isReady) {
@@ -69,10 +69,10 @@ - (void)handleResponse:(NSDictionary *)data {
6969
//If this is an error response, trigger the callback right away
7070
if (error) {
7171
NSString *msg = payload[@"errorMessage"];
72-
id codeObj = payload[@"code"];
72+
id codeObj = payload[@"errorCode"];
7373
NSError *error;
7474
if (codeObj == nil) {
75-
error = [NSError errorWithDomain:ZPCErrorDomain code:ZPCErrorUnavailable userInfo:@{@"errorMsg": @"Unknown error"}];
75+
error = [NSError errorWithDomain:ZPCErrorDomain code:ZPCFailedToStartError userInfo:@{@"errorMsg": @"Unknown error"}];
7676
} else {
7777
error = [NSError errorWithDomain:ZPCErrorDomain code:[codeObj intValue] userInfo:@{@"errorMsg": msg}];
7878
}
@@ -102,7 +102,7 @@ - (void)sendQuery:(NSString *)dataType withCompletionHandler:(ResponseBlock)comp
102102
//If requests cant be processed now, cancel immediately
103103
if (!_isReady) {
104104
NSError *error = [NSError errorWithDomain:ZPCErrorDomain
105-
code:ZPCErrorUnavailable
105+
code:ZPCFailedToStartError
106106
userInfo:nil];
107107

108108
completionHandler(nil, error);
@@ -129,7 +129,7 @@ - (void)sendQuery:(NSString *)dataType withCompletionHandler:(ResponseBlock)comp
129129
- (void)failAllQueries {
130130
for (NSString *requestId in _requests) {
131131
NSError *error = [NSError errorWithDomain:ZPCErrorDomain
132-
code:ZPCErrorUnavailable
132+
code:ZPCFailedToStartError
133133
userInfo:nil];
134134

135135
//Gets the handler

Assets/Plugins/iOS/Zapic/Controllers/Zapic.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#import <UIKit/UIKit.h>
22
#import "ZPCChallenge.h"
33
#import "ZPCCompetition.h"
4+
#import "ZPCErrors.h"
45
#import "ZPCPlayer.h"
56
#import "ZPCStatistic.h"
67

0 commit comments

Comments
 (0)