mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Fix error handling of invalid commandline options
This commit is contained in:
parent
06544d31e1
commit
0070a08109
2 changed files with 16 additions and 5 deletions
|
@ -118,7 +118,11 @@ public class SentryErrorHandler implements ErrorHandler {
|
|||
|
||||
return copy;
|
||||
} catch (Exception e) {
|
||||
if (AppLogs.get() != null) AppLogs.get().logException("Unable to adjust exception", e);
|
||||
// This can fail for example when the underlying exception is not serializable
|
||||
// and comes from some third party library
|
||||
if (AppLogs.get() != null) {
|
||||
AppLogs.get().logException("Unable to adjust exception", e);
|
||||
}
|
||||
return throwable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,14 +47,14 @@ public class LauncherCommand implements Callable<Integer> {
|
|||
|
||||
var cmd = new CommandLine(new LauncherCommand());
|
||||
cmd.setExecutionExceptionHandler((ex, commandLine, parseResult) -> {
|
||||
var event = ErrorEvent.fromThrowable("Launcher command error occurred", ex).term().build();
|
||||
var event = ErrorEvent.fromThrowable(ex).term().build();
|
||||
// Print error in case we launched from the command-line
|
||||
new LogErrorHandler().handle(event);
|
||||
event.handle();
|
||||
return 1;
|
||||
});
|
||||
cmd.setParameterExceptionHandler((ex, args1) -> {
|
||||
var event = ErrorEvent.fromThrowable("Launcher parameter error occurred", ex).term().build();
|
||||
var event = ErrorEvent.fromThrowable(ex).term().build();
|
||||
// Print error in case we launched from the command-line
|
||||
new LogErrorHandler().handle(event);
|
||||
event.handle();
|
||||
|
@ -65,8 +65,15 @@ public class LauncherCommand implements Callable<Integer> {
|
|||
cmd.setOut(new PrintWriter(AppLogs.get().getOriginalSysOut()));
|
||||
cmd.setErr(new PrintWriter(AppLogs.get().getOriginalSysErr()));
|
||||
|
||||
try {
|
||||
cmd.parseArgs(args);
|
||||
cmd.execute(args);
|
||||
} catch (Throwable t) {
|
||||
var e = ErrorEvent.fromThrowable(t).term().build();
|
||||
// Print error in case we launched from the command-line
|
||||
new LogErrorHandler().handle(e);
|
||||
e.handle();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkStart() {
|
||||
|
|
Loading…
Reference in a new issue