Skip to content

Commit

Permalink
Fix CannotParseException
Browse files Browse the repository at this point in the history
Added logging of messages that weren't parsed.
  • Loading branch information
TomasKypta committed Sep 26, 2016
1 parent c2685d8 commit aced598
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

VERSION = 3.4.0
VERSION = 3.4.1
MIN_SDK = 10
TARGET_SDK = 22
INITIAL_VERSION_CODE = 300180
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ protected Time parseDate(String sms, String datePattern, Ticket ticket) throws P
}
}

throw new ParseException("Cannot parse date from the message " + sms, 0);
throw new ParseException("Cannot parse date from the message: " + sms, 0);
}

protected String parseHash(String sms) {
Expand All @@ -234,7 +234,7 @@ protected String parseHash(String sms) {
return m.group(1);
}

throw new CannotParseException("Cannot parse hash from the message");
throw new CannotParseException("Cannot parse hash from the message: " + sms);
}

public boolean acceptMessage(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@
import android.support.annotation.NonNull;
import android.telephony.SmsMessage;

import com.crashlytics.android.Crashlytics;

import eu.inmite.apps.smsjizdenka.data.Preferences;
import eu.inmite.apps.smsjizdenka.data.TicketProvider;
import eu.inmite.apps.smsjizdenka.data.model.City;
import eu.inmite.apps.smsjizdenka.data.model.CityManager;
import eu.inmite.apps.smsjizdenka.data.model.Ticket;
import eu.inmite.apps.smsjizdenka.framework.DebugLog;
import eu.inmite.apps.smsjizdenka.service.SmsReceiverService;
import eu.inmite.apps.smsjizdenka.util.CannotParseException;

/**
* Receives system broadcasts about receiving sms <code>android.provider.Telephony.SMS_RECEIVED</code> and checks if
Expand Down Expand Up @@ -167,7 +170,13 @@ public synchronized void processTicket(Context c, @NonNull SmsMessage m) throws
} */

for (City city : cities) {
final Ticket t = city.parseMessage(message);
final Ticket t;
try {
t = city.parseMessage(message);
} catch (CannotParseException e) {
Crashlytics.log("Cannot parse message: " + message);
continue;
}
if (!alreadyProcessed(c, t)) {
SmsReceiverService.call(c, t);
if (!Preferences.getBoolean(c, Preferences.KEEP_IN_MESSAGING, false)) {
Expand Down

0 comments on commit aced598

Please sign in to comment.