Print stack trace of exception causes in verbose mode

This commit is contained in:
AsamK 2021-09-08 20:38:24 +02:00
parent e3c37a0239
commit 2044a7d7a5
32 changed files with 66 additions and 60 deletions

View file

@ -16,6 +16,7 @@ import org.asamk.signal.commands.ProvisioningCommand;
import org.asamk.signal.commands.RegistrationCommand; import org.asamk.signal.commands.RegistrationCommand;
import org.asamk.signal.commands.SignalCreator; import org.asamk.signal.commands.SignalCreator;
import org.asamk.signal.commands.exceptions.CommandException; import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UnexpectedErrorException; import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException; import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.Manager;
@ -225,7 +226,7 @@ public class App {
+ e.getMessage() + e.getMessage()
+ " (" + " ("
+ e.getClass().getSimpleName() + e.getClass().getSimpleName()
+ ")"); + ")", e);
} }
try (var m = manager) { try (var m = manager) {
command.handleCommand(ns, m); command.handleCommand(ns, m);
@ -299,20 +300,19 @@ public class App {
} catch (NotRegisteredException e) { } catch (NotRegisteredException e) {
throw new UserErrorException("User " + username + " is not registered."); throw new UserErrorException("User " + username + " is not registered.");
} catch (Throwable e) { } catch (Throwable e) {
logger.debug("Loading state file failed", e);
throw new UnexpectedErrorException("Error loading state file for user " throw new UnexpectedErrorException("Error loading state file for user "
+ username + username
+ ": " + ": "
+ e.getMessage() + e.getMessage()
+ " (" + " ("
+ e.getClass().getSimpleName() + e.getClass().getSimpleName()
+ ")"); + ")", e);
} }
try { try {
manager.checkAccountState(); manager.checkAccountState();
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Error while checking account " + username + ": " + e.getMessage()); throw new IOErrorException("Error while checking account " + username + ": " + e.getMessage(), e);
} }
return manager; return manager;
@ -337,7 +337,7 @@ public class App {
} }
} catch (DBusException | IOException e) { } catch (DBusException | IOException e) {
logger.error("Dbus client failed", e); logger.error("Dbus client failed", e);
throw new UnexpectedErrorException("Dbus client failed"); throw new UnexpectedErrorException("Dbus client failed", e);
} }
} }

View file

@ -40,7 +40,8 @@ public class Main {
installSecurityProviderWorkaround(); installSecurityProviderWorkaround();
// Configuring the logger needs to happen before any logger is initialized // Configuring the logger needs to happen before any logger is initialized
configureLogging(isVerbose(args)); final var isVerbose = isVerbose(args);
configureLogging(isVerbose);
var parser = App.buildArgumentParser(); var parser = App.buildArgumentParser();
@ -51,6 +52,9 @@ public class Main {
new App(ns).init(); new App(ns).init();
} catch (CommandException e) { } catch (CommandException e) {
System.err.println(e.getMessage()); System.err.println(e.getMessage());
if (isVerbose && e.getCause() != null) {
e.getCause().printStackTrace();
}
status = getStatusForError(e); status = getStatusForError(e);
} }
System.exit(status); System.exit(status);

View file

@ -42,12 +42,12 @@ public class AddDeviceCommand implements JsonRpcLocalCommand {
m.addDeviceLink(new URI(ns.getString("uri"))); m.addDeviceLink(new URI(ns.getString("uri")));
} catch (IOException e) { } catch (IOException e) {
logger.error("Add device link failed", e); logger.error("Add device link failed", e);
throw new IOErrorException("Add device link failed"); throw new IOErrorException("Add device link failed", e);
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
throw new UserErrorException("Device link uri has invalid format: " + e.getMessage()); throw new UserErrorException("Device link uri has invalid format: " + e.getMessage());
} catch (InvalidKeyException e) { } catch (InvalidKeyException e) {
logger.error("Add device link failed", e); logger.error("Add device link failed", e);
throw new UnexpectedErrorException("Add device link failed."); throw new UnexpectedErrorException("Add device link failed.", e);
} }
} }
} }

View file

@ -43,7 +43,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
} catch (NotMasterDeviceException e) { } catch (NotMasterDeviceException e) {
throw new UserErrorException("This command doesn't work on linked devices."); throw new UserErrorException("This command doesn't work on linked devices.");
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage()); throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
} }
} }
@ -55,7 +55,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
} catch (GroupNotFoundException e) { } catch (GroupNotFoundException e) {
logger.warn("Group not found {}: {}", groupId.toBase64(), e.getMessage()); logger.warn("Group not found {}: {}", groupId.toBase64(), e.getMessage());
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage()); throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
} }
} }
} }

View file

@ -75,7 +75,7 @@ public class DaemonCommand implements MultiLocalCommand {
} }
} catch (DBusException | IOException e) { } catch (DBusException | IOException e) {
logger.error("Dbus command failed", e); logger.error("Dbus command failed", e);
throw new UnexpectedErrorException("Dbus command failed"); throw new UnexpectedErrorException("Dbus command failed", e);
} }
} }
@ -113,7 +113,7 @@ public class DaemonCommand implements MultiLocalCommand {
signalControl.run(); signalControl.run();
} catch (DBusException | IOException e) { } catch (DBusException | IOException e) {
logger.error("Dbus command failed", e); logger.error("Dbus command failed", e);
throw new UnexpectedErrorException("Dbus command failed"); throw new UnexpectedErrorException("Dbus command failed", e);
} }
} }

View file

@ -43,8 +43,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
try { try {
registered = m.areUsersRegistered(new HashSet<>(ns.getList("recipient"))); registered = m.areUsersRegistered(new HashSet<>(ns.getList("recipient")));
} catch (IOException e) { } catch (IOException e) {
logger.debug("Failed to check registered users", e); throw new IOErrorException("Unable to check if users are registered", e);
throw new IOErrorException("Unable to check if users are registered");
} }
// Output // Output

View file

@ -78,10 +78,10 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
+ e.getMessage() + e.getMessage()
+ " (" + " ("
+ e.getClass().getSimpleName() + e.getClass().getSimpleName()
+ ")"); + ")", e);
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} catch (GroupLinkNotActiveException e) { } catch (GroupLinkNotActiveException e) {
throw new UserErrorException("Group link is not valid: " + e.getMessage()); throw new UserErrorException("Group link is not valid: " + e.getMessage());
} }

View file

@ -49,7 +49,7 @@ public class LinkCommand implements ProvisioningCommand {
} catch (TimeoutException e) { } catch (TimeoutException e) {
throw new UserErrorException("Link request timed out, please try again."); throw new UserErrorException("Link request timed out, please try again.");
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Link request error: " + e.getMessage()); throw new IOErrorException("Link request error: " + e.getMessage(), e);
} catch (UserAlreadyExists e) { } catch (UserAlreadyExists e) {
throw new UserErrorException("The user " throw new UserErrorException("The user "
+ e.getUsername() + e.getUsername()

View file

@ -40,8 +40,7 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
try { try {
devices = m.getLinkedDevices(); devices = m.getLinkedDevices();
} catch (IOException e) { } catch (IOException e) {
logger.debug("Failed to get linked devices", e); throw new IOErrorException("Failed to get linked devices: " + e.getMessage(), e);
throw new IOErrorException("Failed to get linked devices: " + e.getMessage());
} }
if (outputWriter instanceof PlainTextWriter) { if (outputWriter instanceof PlainTextWriter) {
@ -71,10 +70,7 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
public final long lastSeenTimestamp; public final long lastSeenTimestamp;
private JsonDevice( private JsonDevice(
final long id, final long id, final String name, final long createdTimestamp, final long lastSeenTimestamp
final String name,
final long createdTimestamp,
final long lastSeenTimestamp
) { ) {
this.id = id; this.id = id;
this.name = name; this.name = name;

View file

@ -70,7 +70,7 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
+ e.getMessage() + e.getMessage()
+ " (" + " ("
+ e.getClass().getSimpleName() + e.getClass().getSimpleName()
+ ")"); + ")", e);
} catch (GroupNotFoundException e) { } catch (GroupNotFoundException e) {
throw new UserErrorException("Failed to send to group: " + e.getMessage()); throw new UserErrorException("Failed to send to group: " + e.getMessage());
} catch (LastGroupAdminException e) { } catch (LastGroupAdminException e) {

View file

@ -126,7 +126,7 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
} }
} catch (DBusException e) { } catch (DBusException e) {
logger.error("Dbus client failed", e); logger.error("Dbus client failed", e);
throw new UnexpectedErrorException("Dbus client failed"); throw new UnexpectedErrorException("Dbus client failed", e);
} }
while (true) { while (true) {
try { try {
@ -157,7 +157,7 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
ignoreAttachments, ignoreAttachments,
handler); handler);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Error while receiving messages: " + e.getMessage()); throw new IOErrorException("Error while receiving messages: " + e.getMessage(), e);
} }
} }
} }

View file

@ -49,7 +49,7 @@ public class RegisterCommand implements RegistrationCommand {
} }
throw new UserErrorException(message); throw new UserErrorException(message);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Request verify error: " + e.getMessage()); throw new IOErrorException("Request verify error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -65,7 +65,7 @@ public class RemoteDeleteCommand implements DbusCommand, JsonRpcLocalCommand {
throw new UserErrorException(e.getMessage()); throw new UserErrorException(e.getMessage());
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }
@ -106,7 +106,7 @@ public class RemoteDeleteCommand implements DbusCommand, JsonRpcLocalCommand {
throw new UserErrorException("Failed to send to group: " + e.getMessage()); throw new UserErrorException("Failed to send to group: " + e.getMessage());
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }

View file

@ -34,7 +34,7 @@ public class RemoveDeviceCommand implements JsonRpcLocalCommand {
int deviceId = ns.getInt("device-id"); int deviceId = ns.getInt("device-id");
m.removeLinkedDevices(deviceId); m.removeLinkedDevices(deviceId);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Error while removing device: " + e.getMessage()); throw new IOErrorException("Error while removing device: " + e.getMessage(), e);
} }
} }
} }

View file

@ -32,9 +32,9 @@ public class RemovePinCommand implements JsonRpcLocalCommand {
try { try {
m.setRegistrationLockPin(Optional.absent()); m.setRegistrationLockPin(Optional.absent());
} catch (UnauthenticatedResponseException e) { } catch (UnauthenticatedResponseException e) {
throw new UnexpectedErrorException("Remove pin failed with unauthenticated response: " + e.getMessage()); throw new UnexpectedErrorException("Remove pin failed with unauthenticated response: " + e.getMessage(), e);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Remove pin error: " + e.getMessage()); throw new IOErrorException("Remove pin error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -86,7 +86,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
return; return;
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }
@ -110,7 +110,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
ErrorUtils.handleSendMessageResults(results.getResults()); ErrorUtils.handleSendMessageResults(results.getResults());
} catch (AttachmentInvalidException | IOException e) { } catch (AttachmentInvalidException | IOException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) { } catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
throw new UserErrorException(e.getMessage()); throw new UserErrorException(e.getMessage());
} }
@ -147,7 +147,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
.getSimpleName() + ")"); .getSimpleName() + ")");
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }
@ -176,7 +176,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
outputResult(outputWriter, timestamp); outputResult(outputWriter, timestamp);
return; return;
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send group message: " + e.getMessage()); throw new UnexpectedErrorException("Failed to send group message: " + e.getMessage(), e);
} }
} }
@ -189,7 +189,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
throw new UntrustedKeyErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UntrustedKeyErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")");
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send note to self message: " + e.getMessage()); throw new UnexpectedErrorException("Failed to send note to self message: " + e.getMessage(), e);
} }
} }
@ -203,7 +203,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
.getSimpleName() + ")"); .getSimpleName() + ")");
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }

View file

@ -29,7 +29,7 @@ public class SendContactsCommand implements JsonRpcLocalCommand {
try { try {
m.sendContacts(); m.sendContacts();
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("SendContacts error: " + e.getMessage()); throw new IOErrorException("SendContacts error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -81,7 +81,7 @@ public class SendReactionCommand implements DbusCommand, JsonRpcLocalCommand {
throw new UserErrorException(e.getMessage()); throw new UserErrorException(e.getMessage());
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }
@ -129,7 +129,7 @@ public class SendReactionCommand implements DbusCommand, JsonRpcLocalCommand {
throw new UserErrorException("Failed to send to group: " + e.getMessage()); throw new UserErrorException("Failed to send to group: " + e.getMessage());
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }

View file

@ -29,7 +29,7 @@ public class SendSyncRequestCommand implements JsonRpcLocalCommand {
try { try {
m.requestAllSyncData(); m.requestAllSyncData();
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Request sync data error: " + e.getMessage()); throw new IOErrorException("Request sync data error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -35,9 +35,10 @@ public class SetPinCommand implements JsonRpcLocalCommand {
var registrationLockPin = ns.getString("pin"); var registrationLockPin = ns.getString("pin");
m.setRegistrationLockPin(Optional.of(registrationLockPin)); m.setRegistrationLockPin(Optional.of(registrationLockPin));
} catch (UnauthenticatedResponseException e) { } catch (UnauthenticatedResponseException e) {
throw new UnexpectedErrorException("Set pin error failed with unauthenticated response: " + e.getMessage()); throw new UnexpectedErrorException("Set pin error failed with unauthenticated response: " + e.getMessage(),
e);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Set pin error: " + e.getMessage()); throw new IOErrorException("Set pin error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -42,7 +42,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
} catch (NotMasterDeviceException e) { } catch (NotMasterDeviceException e) {
throw new UserErrorException("This command doesn't work on linked devices."); throw new UserErrorException("This command doesn't work on linked devices.");
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage()); throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e);
} }
} }
@ -53,7 +53,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
} catch (GroupNotFoundException e) { } catch (GroupNotFoundException e) {
logger.warn("Unknown group id: {}", groupId); logger.warn("Unknown group id: {}", groupId);
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage()); throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e);
} }
} }
} }

View file

@ -37,7 +37,7 @@ public class UnregisterCommand implements LocalCommand {
m.unregister(); m.unregister();
} }
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Unregister error: " + e.getMessage()); throw new IOErrorException("Unregister error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -31,7 +31,7 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
try { try {
m.updateAccountAttributes(deviceName); m.updateAccountAttributes(deviceName);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("UpdateAccount error: " + e.getMessage()); throw new IOErrorException("UpdateAccount error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -46,7 +46,7 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
m.setContactName(recipient, name); m.setContactName(recipient, name);
} }
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Update contact error: " + e.getMessage()); throw new IOErrorException("Update contact error: " + e.getMessage(), e);
} catch (NotMasterDeviceException e) { } catch (NotMasterDeviceException e) {
throw new UserErrorException("This command doesn't work on linked devices."); throw new UserErrorException("This command doesn't work on linked devices.");
} }

View file

@ -175,7 +175,7 @@ public class UpdateGroupCommand implements DbusCommand, JsonRpcLocalCommand {
throw new UserErrorException(e.getMessage()); throw new UserErrorException(e.getMessage());
} catch (IOException e) { } catch (IOException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }
@ -212,7 +212,7 @@ public class UpdateGroupCommand implements DbusCommand, JsonRpcLocalCommand {
throw new UserErrorException("Failed to add avatar attachment for group\": " + e.getMessage()); throw new UserErrorException("Failed to add avatar attachment for group\": " + e.getMessage());
} catch (DBusExecutionException e) { } catch (DBusExecutionException e) {
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass() throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")"); .getSimpleName() + ")", e);
} }
} }

View file

@ -51,7 +51,7 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
try { try {
m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile); m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Update profile error: " + e.getMessage()); throw new IOErrorException("Update profile error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -50,7 +50,7 @@ public class UploadStickerPackCommand implements JsonRpcLocalCommand {
writer.write(Map.of("url", url)); writer.write(Map.of("url", url));
} }
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Upload error (maybe image size too large):" + e.getMessage()); throw new IOErrorException("Upload error (maybe image size too large):" + e.getMessage(), e);
} catch (StickerPackInvalidException e) { } catch (StickerPackInvalidException e) {
throw new UserErrorException("Invalid sticker pack: " + e.getMessage()); throw new UserErrorException("Invalid sticker pack: " + e.getMessage());
} }

View file

@ -44,9 +44,9 @@ public class VerifyCommand implements RegistrationCommand {
} catch (KeyBackupServicePinException e) { } catch (KeyBackupServicePinException e) {
throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e.getTriesRemaining()); throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e.getTriesRemaining());
} catch (KeyBackupSystemNoDataException e) { } catch (KeyBackupSystemNoDataException e) {
throw new UnexpectedErrorException("Verification failed! No KBS data."); throw new UnexpectedErrorException("Verification failed! No KBS data.", e);
} catch (IOException e) { } catch (IOException e) {
throw new IOErrorException("Verify error: " + e.getMessage()); throw new IOErrorException("Verify error: " + e.getMessage(), e);
} }
} }
} }

View file

@ -5,4 +5,8 @@ public class CommandException extends Exception {
public CommandException(final String message) { public CommandException(final String message) {
super(message); super(message);
} }
public CommandException(final String message, final Throwable cause) {
super(message, cause);
}
} }

View file

@ -1,8 +1,10 @@
package org.asamk.signal.commands.exceptions; package org.asamk.signal.commands.exceptions;
import java.io.IOException;
public final class IOErrorException extends CommandException { public final class IOErrorException extends CommandException {
public IOErrorException(final String message) { public IOErrorException(final String message, IOException cause) {
super(message); super(message, cause);
} }
} }

View file

@ -2,7 +2,7 @@ package org.asamk.signal.commands.exceptions;
public final class UnexpectedErrorException extends CommandException { public final class UnexpectedErrorException extends CommandException {
public UnexpectedErrorException(final String message) { public UnexpectedErrorException(final String message, final Throwable cause) {
super(message); super(message, cause);
} }
} }

View file

@ -88,6 +88,6 @@ public class ErrorUtils {
for (var error : errors) { for (var error : errors) {
message.append(error).append("\n"); message.append(error).append("\n");
} }
throw new IOErrorException(message.toString()); throw new IOErrorException(message.toString(), null);
} }
} }