Skip to content

Commit

Permalink
skip invalid json read in from the queued items file
Browse files Browse the repository at this point in the history
  • Loading branch information
sbezboro committed May 14, 2014
1 parent 72d0e97 commit 2d5aa88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Objective-C library for crash reporting and logging with [Rollbar](https://rollb

## Setup

1. Download the [Rollbar framework](https://github.com/rollbar/rollbar-ios/releases/download/v0.0.5/Rollbar.zip).
1. Download the [Rollbar framework](https://github.com/rollbar/rollbar-ios/releases/download/v0.1.1/Rollbar.zip).

2. Extract the Rollbar directory in the zip file to your Xcode project directory.

Expand Down
13 changes: 10 additions & 3 deletions Rollbar/RollbarNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <sys/utsname.h>


static NSString *NOTIFIER_VERSION = @"0.1.0";
static NSString *NOTIFIER_VERSION = @"0.1.1";
static NSString *QUEUED_ITEMS_FILE_NAME = @"rollbar.items";
static NSString *STATE_FILE_NAME = @"rollbar.state";

Expand Down Expand Up @@ -142,6 +142,12 @@ - (void)processSavedItems {
[reader enumerateLinesUsingBlock:^(NSString *line, NSUInteger nextOffset, BOOL *stop) {
NSDictionary *payload = [NSJSONSerialization JSONObjectWithData:[line dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];

if (!payload) {
// Ignore this line if it isn't valid json and proceed to the next line
// TODO: report an internal error
return;
}

NSString *accessToken = payload[@"access_token"];

// If the max batch size is reached as the file is being processed,
Expand All @@ -150,8 +156,9 @@ - (void)processSavedItems {
BOOL shouldContinue = [self sendItems:items withAccessToken:lastAccessToken nextOffset:nextOffset];

if (!shouldContinue) {
// Return so that the current file offset will be retried next time the
// file is processed
// Stop processing the file so that the current file offset will be
// retried next time the file is processed
*stop = YES;
return;
}

Expand Down

0 comments on commit 2d5aa88

Please sign in to comment.