Let saving as .svg exceptions propagate

This commit is contained in:
Lonami Exo 2017-01-19 12:02:03 +01:00
parent 1acc5e2498
commit eea21a185c
2 changed files with 12 additions and 15 deletions

View File

@ -12,17 +12,12 @@ import java.util.Map;
public class Svg {
public static boolean saveSvg(File output, MyCanvas canvas) {
try {
public static void saveSvg(File output, MyCanvas canvas)
throws IOException {
FileOutputStream out = new FileOutputStream(output);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
writeSvg(writer, canvas.getPaths(), canvas.getWidth(), canvas.getHeight());
writer.close();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
private static void writeSvg(Writer writer,

View File

@ -218,7 +218,7 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange
MediaScannerConnection.scanFile(getApplicationContext(),
new String[]{file.getAbsolutePath()}, null, null);
} catch (Exception e) {
Log.e(TAG, "MainActivity SaveFile " + e.getMessage());
Log.e(TAG, "MainActivity SaveFile (.png) " + e.getMessage());
return false;
} finally {
try {
@ -226,14 +226,16 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange
out.close();
}
} catch (IOException e) {
Log.e(TAG, "MainActivity SaveFile 2 " + e.getMessage());
Log.e(TAG, "MainActivity SaveFile (.png) 2 " + e.getMessage());
}
}
break;
case ".svg":
if (!Svg.saveSvg(file, mMyCanvas)) {
Log.e(TAG, "MainActivity SaveFile failed.");
try {
Svg.saveSvg(file, mMyCanvas);
} catch (IOException e) {
Log.e(TAG, "MainActivity SaveFile (.svg) " + e.getMessage());
return false;
}
break;