review fixes

This commit is contained in:
sergiorussia
2019-05-01 00:18:47 +03:00
parent 557e615862
commit f7a5092116
3 changed files with 47 additions and 49 deletions
@@ -161,7 +161,20 @@ public abstract class Getdown extends Thread
} catch (Exception e) {
log.warning("run() failed.", e);
fail(e);
String msg = e.getMessage();
if (msg == null) {
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
} else if (!msg.startsWith("m.")) {
// try to do something sensible based on the type of error
if (e instanceof FileNotFoundException) {
msg = MessageUtil.compose(
"m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
} else {
msg = MessageUtil.compose(
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
}
}
fail(msg);
}
}
@@ -410,7 +423,22 @@ public abstract class Getdown extends Thread
} catch (Exception e) {
log.warning("getdown() failed.", e);
fail(e);
String msg = e.getMessage();
if (msg == null) {
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
} else if (!msg.startsWith("m.")) {
// try to do something sensible based on the type of error
if (e instanceof FileNotFoundException) {
msg = MessageUtil.compose(
"m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
} else {
msg = MessageUtil.compose(
"m.init_error", MessageUtil.taint(msg), _ifc.installError);
}
}
// Since we're dead, clear off the 'time remaining' label along with displaying the
// error message
fail(msg);
_app.releaseLock();
}
}
@@ -808,21 +836,6 @@ public abstract class Getdown extends Thread
}
}
private void fail(Exception e) {
String msg = e.getMessage();
if (msg == null) {
msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
} else if (!msg.startsWith("m.")) {
// try to do something sensible based on the type of error
if (e instanceof FileNotFoundException) {
msg = MessageUtil.compose("m.missing_resource", MessageUtil.taint(msg), _ifc.installError);
} else {
msg = MessageUtil.compose("m.init_error", MessageUtil.taint(msg), _ifc.installError);
}
}
fail(msg);
}
/**
* Update the status to indicate getdown has failed for the reason in <code>message</code>.
*/