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 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);
|
||||
|
||||
// script finished successfully
|
||||
log.finest("Done ヾ(@⌒ー⌒@)ノ");
|
||||
return SUCCESS;
|
||||
return finish(SUCCESS);
|
||||
} 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)
|
||||
log.finest("Failure (°_°)");
|
||||
return exitCode;
|
||||
return finish(getExitCode(e));
|
||||
}
|
||||
}
|
||||
|
||||
private int finish(int code) {
|
||||
log.finest(format("%s %s", getErrorMessage(code), getErrorKaomoji(code)));
|
||||
return code;
|
||||
}
|
||||
|
||||
private int getExitCode(Throwable e) {
|
||||
if (findCause(e, LicenseError.class) != null) {
|
||||
log.severe(message("License Error", e.getMessage()));
|
||||
|
Loading…
Reference in New Issue
Block a user