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/standard
app/samsung app/samsung
*~ *~
*.log

View file

@ -2,6 +2,8 @@ package com.wbrawner.simplemarkdown.model;
import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.utility.Utils;
import org.acra.ACRA;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -109,7 +111,7 @@ public class MarkdownFile {
this.content = sb.toString(); this.content = sb.toString();
return true; return true;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} finally { } finally {
Utils.closeQuietly(reader); Utils.closeQuietly(reader);
@ -130,6 +132,7 @@ public class MarkdownFile {
this.path = markdownFile.getParentFile().getAbsolutePath(); this.path = markdownFile.getParentFile().getAbsolutePath();
return load(new FileInputStream(markdownFile)); return load(new FileInputStream(markdownFile));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} }
} }
@ -150,7 +153,7 @@ public class MarkdownFile {
return false; return false;
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} }
} }
@ -166,12 +169,14 @@ public class MarkdownFile {
); );
writer.write(this.content); writer.write(this.content);
} catch (IOException e) { } catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
return false; return false;
} finally { } finally {
if (writer != null) { if (writer != null) {
try { try {
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e) {
ACRA.getErrorReporter().handleException(e, false);
// closing the reader failed // 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.MarkdownEditView;
import com.wbrawner.simplemarkdown.view.MarkdownPreviewView; import com.wbrawner.simplemarkdown.view.MarkdownPreviewView;
import org.acra.ACRA;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -52,8 +54,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
InputStream in = new FileInputStream(file); InputStream in = new FileInputStream(file);
loadMarkdown(file.getName(), in); loadMarkdown(file.getName(), in);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.err.println(e.getLocalizedMessage()); ACRA.getErrorReporter().handleException(e, false);
e.printStackTrace();
} }
} }
@ -206,6 +207,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
} }
loadMarkdown(fileName, in); loadMarkdown(fileName, in);
} catch (Exception e) { } catch (Exception e) {
ACRA.getErrorReporter().handleException(e, false);
if (editView != null) { if (editView != null) {
editView.onFileLoaded(false); 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.Constants;
import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.utility.Utils;
import org.acra.ACRA;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -117,6 +119,7 @@ public class ExplorerActivity extends AppCompatActivity {
try { try {
sdcardSelected = filePath.get().contains(mounts[1].getAbsolutePath()); sdcardSelected = filePath.get().contains(mounts[1].getAbsolutePath());
} catch (NullPointerException e) { } catch (NullPointerException e) {
ACRA.getErrorReporter().handleException(e, false);
updateListView(); updateListView();
menu.findItem(R.id.action_use_sdcard).setVisible(false); menu.findItem(R.id.action_use_sdcard).setVisible(false);
// TODO: Report this? // 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.DisableableViewPager;
import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter; import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter;
import org.acra.ACRA;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
@ -164,6 +166,7 @@ public class MainActivity extends AppCompatActivity
} }
}); });
} catch (Exception e) { } catch (Exception e) {
ACRA.getErrorReporter().handleException(e, false);
Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT).show(); Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT).show();
} }
} }

View file

@ -6,7 +6,7 @@ buildscript {
google() google()
} }
dependencies { 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }