Fix crash if FileNotFound exception thrown

This commit is contained in:
misaochan 2016-06-19 19:14:54 +12:00
parent da2397be3d
commit afcc7e0ecb
2 changed files with 5 additions and 2 deletions

View file

@ -163,6 +163,7 @@ public class UploadService extends HandlerService<Contribution> {
return START_REDELIVER_INTENT; return START_REDELIVER_INTENT;
} }
private void uploadContribution(Contribution contribution) { private void uploadContribution(Contribution contribution) {
MWApi api = app.getApi(); MWApi api = app.getApi();
@ -171,11 +172,12 @@ public class UploadService extends HandlerService<Contribution> {
String notificationTag = contribution.getLocalUri().toString(); String notificationTag = contribution.getLocalUri().toString();
try { try {
file = this.getContentResolver().openInputStream(contribution.getLocalUri()); file = this.getContentResolver().openInputStream(contribution.getLocalUri());
} catch(FileNotFoundException e) { } catch(FileNotFoundException e) {
throw new RuntimeException(e); Log.d("Exception", "File not found");
Toast fileNotFound = Toast.makeText(this, R.string.upload_failed, Toast.LENGTH_LONG);
fileNotFound.show();
} }
Log.d("Commons", "Before execution!"); Log.d("Commons", "Before execution!");

View file

@ -10,6 +10,7 @@
<string name="logging_in_message">Please wait...</string> <string name="logging_in_message">Please wait...</string>
<string name="login_success">Login success!</string> <string name="login_success">Login success!</string>
<string name="login_failed">Login failed!</string> <string name="login_failed">Login failed!</string>
<string name="upload_failed">File not found, please try another file</string>
<string name="authentication_failed">Authentication failed!</string> <string name="authentication_failed">Authentication failed!</string>
<string name="uploading_started">Upload started!</string> <string name="uploading_started">Upload started!</string>