Added I/O try-catch and toasts

This commit is contained in:
2026-09-21 12:55:33 -07:00
committed by Tom
parent 338a7e4c0e
commit 8249c68266
2 changed files with 15 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ import com.majinnaibu.monstercards.importers.Open5eImporter;
import com.majinnaibu.monstercards.models.Monster;
import com.majinnaibu.monstercards.utils.Logger;
import com.majinnaibu.monstercards.utils.SnackbarHelper;
import com.majinnaibu.monstercards.utils.ToastHelper;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -212,6 +213,10 @@ public class MCFragment extends Fragment {
}
} catch (Exception e) {
Logger.logError("Error reading URI contents for import", e);
Context ctx = getContext();
if (ctx != null) {
ToastHelper.showLong(ctx, "An error occurred while reading the file.");
}
return null;
}
return builder.toString();