Skip to content

Commit 233a47e

Browse files
author
Alexis Oyama
committed
fix(request): Try/Catch block for NSOperationQueue
1 parent 30ec6aa commit 233a47e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Leanplum-SDK/Classes/LeanplumRequest.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ - (void)sendRequests:(BOOL)async
305305
__weak NSBlockOperation *weakOperation = requestOperation;
306306

307307
void (^operationBlock)(void) = ^void() {
308+
LP_TRY
308309
if ([weakOperation isCancelled]) {
309310
return;
310311
}
@@ -340,6 +341,7 @@ - (void)sendRequests:(BOOL)async
340341

341342
// Request callbacks.
342343
[op addCompletionHandler:^(id<LPNetworkOperationProtocol> operation, id json) {
344+
LP_TRY
343345
if ([weakOperation isCancelled]) {
344346
dispatch_semaphore_signal(semaphore);
345347
return;
@@ -364,14 +366,15 @@ - (void)sendRequests:(BOOL)async
364366
operation:operation];
365367
}
366368
dispatch_semaphore_signal(semaphore);
369+
LP_END_TRY
367370

368371
} errorHandler:^(id<LPNetworkOperationProtocol> completedOperation, NSError *err) {
372+
LP_TRY
369373
if ([weakOperation isCancelled]) {
370374
dispatch_semaphore_signal(semaphore);
371375
return;
372376
}
373377

374-
LP_TRY
375378
// Retry on 500 and other network failures.
376379
NSInteger httpStatusCode = completedOperation.HTTPStatusCode;
377380
if (httpStatusCode == 408
@@ -429,6 +432,7 @@ - (void)sendRequests:(BOOL)async
429432
[[LeanplumRequest sendNowQueue] cancelAllOperations];
430433
LP_END_TRY
431434
}
435+
LP_END_TRY
432436
};
433437

434438
// Send. operationBlock will run synchronously.

0 commit comments

Comments
 (0)