Better error reporting, fix NPE (stupid Gson)

This commit is contained in:
comp500 2019-06-24 03:38:19 +01:00
parent 165c8cc172
commit d18e134140
No known key found for this signature in database
GPG Key ID: 214C822FFEC586B5
2 changed files with 12 additions and 4 deletions

View File

@ -122,7 +122,13 @@ public class Main {
ui.executeManager(new Runnable(){
@Override
public void run() {
try {
new UpdateManager(uOptions, ui);
} catch (Exception e) {
// TODO: better error message?
ui.handleExceptionAndExit(e);
return;
}
}
});
} catch (Exception e) {

View File

@ -110,16 +110,18 @@ public class UpdateManager {
ui.submitProgress(new InstallProgress("Loading manifest file..."));
Gson gson = new Gson();
ManifestFile manifest;
ManifestFile manifest = null;
try {
manifest = gson.fromJson(new FileReader(Paths.get(opts.packFolder, opts.manifestFile).toString()),
ManifestFile.class);
} catch (FileNotFoundException e) {
manifest = new ManifestFile();
} catch (FileNotFoundException e) { // Do nothing
} catch (JsonSyntaxException | JsonIOException e) {
ui.handleExceptionAndExit(e);
return;
}
if (manifest == null) {
manifest = new ManifestFile();
}
ui.submitProgress(new InstallProgress("Loading pack file..."));
GeneralHashingSource packFileSource;