Report errors to ACRA instead of printing

This commit is contained in:
William Brawner 2018-08-31 08:17:14 -05:00 committed by William Brawner
parent 179e872892
commit a737d23ba7
6 changed files with 19 additions and 5 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ IAP5Helper/build
app/standard
app/samsung
*~
*.log

View file

@ -2,6 +2,8 @@ package com.wbrawner.simplemarkdown.model;
import com.wbrawner.simplemarkdown.utility.Utils;
import org.acra.ACRA;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@ -109,7 +111,7 @@ public class MarkdownFile {
this.content = sb.toString();
return true;
} catch (IOException e) {
e.printStackTrace();
ACRA.getErrorReporter().handleException(e, false);
return false;
} finally {
Utils.closeQuietly(reader);
@ -130,6 +132,7 @@ public class MarkdownFile {
this.path = markdownFile.getParentFile().getAbsolutePath();
return load(new FileInputStream(markdownFile));
} catch (FileNotFoundException e) {
ACRA.getErrorReporter().handleException(e, false);
return false;
}
}
@ -150,7 +153,7 @@ public class MarkdownFile {
return false;
}
} catch (IOException e) {
e.printStackTrace();
ACRA.getErrorReporter().handleException(e, false);
return false;
}
}
@ -166,12 +169,14 @@ public class MarkdownFile {
);
writer.write(this.content);
} catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
return false;
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
// closing the reader failed
}
}

View file

@ -12,6 +12,8 @@ import com.wbrawner.simplemarkdown.utility.Utils;
import com.wbrawner.simplemarkdown.view.MarkdownEditView;
import com.wbrawner.simplemarkdown.view.MarkdownPreviewView;
import org.acra.ACRA;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -52,8 +54,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
InputStream in = new FileInputStream(file);
loadMarkdown(file.getName(), in);
} catch (FileNotFoundException e) {
System.err.println(e.getLocalizedMessage());
e.printStackTrace();
ACRA.getErrorReporter().handleException(e, false);
}
}
@ -206,6 +207,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
}
loadMarkdown(fileName, in);
} catch (Exception e) {
ACRA.getErrorReporter().handleException(e, false);
if (editView != null) {
editView.onFileLoaded(false);
}

View file

@ -19,6 +19,8 @@ import com.wbrawner.simplemarkdown.R;
import com.wbrawner.simplemarkdown.utility.Constants;
import com.wbrawner.simplemarkdown.utility.Utils;
import org.acra.ACRA;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@ -117,6 +119,7 @@ public class ExplorerActivity extends AppCompatActivity {
try {
sdcardSelected = filePath.get().contains(mounts[1].getAbsolutePath());
} catch (NullPointerException e) {
ACRA.getErrorReporter().handleException(e, false);
updateListView();
menu.findItem(R.id.action_use_sdcard).setVisible(false);
// TODO: Report this?

View file

@ -24,6 +24,8 @@ import com.wbrawner.simplemarkdown.utility.Utils;
import com.wbrawner.simplemarkdown.view.DisableableViewPager;
import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter;
import org.acra.ACRA;
import java.io.File;
import java.io.InputStream;
@ -164,6 +166,7 @@ public class MainActivity extends AppCompatActivity
}
});
} catch (Exception e) {
ACRA.getErrorReporter().handleException(e, false);
Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT).show();
}
}

View file

@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}