mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-22 15:58:52 -05:00
Refactor error messages / kaomoji
This commit is contained in:
parent
3264436357
commit
8390e65ee9
@ -14,4 +14,42 @@ public interface ExitCode {
|
|||||||
|
|
||||||
public static final int NOOP = 100;
|
public static final int NOOP = 100;
|
||||||
|
|
||||||
|
public static String getErrorMessage(int code) {
|
||||||
|
switch (code) {
|
||||||
|
case SUCCESS:
|
||||||
|
return "Done";
|
||||||
|
case ERROR:
|
||||||
|
return "Error";
|
||||||
|
case BAD_LICENSE:
|
||||||
|
return "Bad License";
|
||||||
|
case FAILURE:
|
||||||
|
return "Failure";
|
||||||
|
case DIE:
|
||||||
|
return "Abort";
|
||||||
|
case NOOP:
|
||||||
|
return "Done";
|
||||||
|
default:
|
||||||
|
return String.format("Error (%d)", code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getErrorKaomoji(int code) {
|
||||||
|
switch (code) {
|
||||||
|
case SUCCESS:
|
||||||
|
return "ヾ(@⌒ー⌒@)ノ";
|
||||||
|
case ERROR:
|
||||||
|
return "(o_O)";
|
||||||
|
case BAD_LICENSE:
|
||||||
|
return "(>_<)";
|
||||||
|
case FAILURE:
|
||||||
|
return "(×_×)⌒☆";
|
||||||
|
case DIE:
|
||||||
|
return "(×_×)";
|
||||||
|
case NOOP:
|
||||||
|
return "¯\\_(ツ)_/¯";
|
||||||
|
default:
|
||||||
|
return "/╲/\\╭[☉﹏☉]╮/\\╱\\";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,17 +37,18 @@ public class ArgumentProcessor {
|
|||||||
runScript(cli, args);
|
runScript(cli, args);
|
||||||
|
|
||||||
// script finished successfully
|
// script finished successfully
|
||||||
log.finest("Done ヾ(@⌒ー⌒@)ノ");
|
return finish(SUCCESS);
|
||||||
return SUCCESS;
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
int exitCode = getExitCode(e);
|
|
||||||
|
|
||||||
// script failed with exception -> exit with non-zero exit code (and use positive code to avoid issues with launch4j launcher)
|
// script failed with exception -> exit with non-zero exit code (and use positive code to avoid issues with launch4j launcher)
|
||||||
log.finest("Failure (°_°)");
|
return finish(getExitCode(e));
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int finish(int code) {
|
||||||
|
log.finest(format("%s %s", getErrorMessage(code), getErrorKaomoji(code)));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
private int getExitCode(Throwable e) {
|
private int getExitCode(Throwable e) {
|
||||||
if (findCause(e, LicenseError.class) != null) {
|
if (findCause(e, LicenseError.class) != null) {
|
||||||
log.severe(message("License Error", e.getMessage()));
|
log.severe(message("License Error", e.getMessage()));
|
||||||
|
Loading…
Reference in New Issue
Block a user