Improve stderr output

This commit is contained in:
AsamK 2020-08-09 15:11:09 +02:00
parent 2c3d222e84
commit 2c5a70cc47
6 changed files with 9 additions and 10 deletions

View file

@ -43,7 +43,7 @@ public class ListIdentitiesCommand implements LocalCommand {
printIdentityFingerprint(m, id);
}
} catch (InvalidNumberException e) {
System.out.println("Invalid number: " + e.getMessage());
System.err.println("Invalid number: " + e.getMessage());
}
}
return 0;

View file

@ -3,11 +3,11 @@ package org.asamk.signal.commands;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import java.io.IOException;
import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import java.io.IOException;
public class UpdateContactCommand implements LocalCommand {
@Override
@ -42,7 +42,8 @@ public class UpdateContactCommand implements LocalCommand {
m.setExpirationTimer(number, expiration);
}
} catch (InvalidNumberException e) {
System.out.println("Invalid contact number: " + e.getMessage());
System.err.println("Invalid contact number: " + e.getMessage());
return 1;
} catch (IOException e) {
System.err.println("Update contact error: " + e.getMessage());
return 3;

View file

@ -556,9 +556,7 @@ public class Manager implements Closeable {
for (ContactTokenDetails contact : contacts) {
newE164Members.remove(contact.getNumber());
}
System.err.println("Failed to add members " + Util.join(", ", newE164Members) + " to group: Not registered on Signal");
System.err.println("Aborting…");
System.exit(1);
throw new IOException("Failed to add members " + Util.join(", ", newE164Members) + " to group: Not registered on Signal");
}
g.addMembers(members);

View file

@ -70,7 +70,7 @@ class JsonPreKeyStore implements PreKeyStore {
try {
preKeyMap.put(preKeyId, Base64.decode(preKey.get("record").asText()));
} catch (IOException e) {
System.out.println(String.format("Error while decoding prekey for: %s", preKeyId));
System.err.println(String.format("Error while decoding prekey for: %s", preKeyId));
}
}
}

View file

@ -153,7 +153,7 @@ class JsonSessionStore implements SessionStore {
SessionInfo sessionInfo = new SessionInfo(serviceAddress, deviceId, Base64.decode(record));
sessionStore.sessions.add(sessionInfo);
} catch (IOException e) {
System.out.println(String.format("Error while decoding session for: %s", sessionName));
System.err.println(String.format("Error while decoding session for: %s", sessionName));
}
}
}

View file

@ -87,7 +87,7 @@ class JsonSignedPreKeyStore implements SignedPreKeyStore {
try {
preKeyMap.put(preKeyId, Base64.decode(preKey.get("record").asText()));
} catch (IOException e) {
System.out.println(String.format("Error while decoding prekey for: %s", preKeyId));
System.err.println(String.format("Error while decoding prekey for: %s", preKeyId));
}
}
}