mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 18:55:58 +02:00
Check for error suggesting another nomulus running (#1582)
Check for a PSQLException referencing a failed connection to "google:5433", which likely indicates that there is another nomulus tool instance running. It's worth giving this hint because in cases like this it's not at all obvious that the other instance of nomulus is problematic.
This commit is contained in:
parent
396e1fb0cf
commit
e74113247f
1 changed files with 21 additions and 3 deletions
|
@ -38,7 +38,9 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import org.postgresql.util.PSQLException;
|
||||||
|
|
||||||
/** Container class to create and run remote commands against a Datastore instance. */
|
/** Container class to create and run remote commands against a Datastore instance. */
|
||||||
@Parameters(separators = " =", commandDescription = "Command-line interface to the registry")
|
@Parameters(separators = " =", commandDescription = "Command-line interface to the registry")
|
||||||
|
@ -178,14 +180,30 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runCommand(command);
|
runCommand(command);
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException e) {
|
||||||
if (Throwables.getRootCause(ex) instanceof LoginRequiredException) {
|
if (Throwables.getRootCause(e) instanceof LoginRequiredException) {
|
||||||
System.err.println("===================================================================");
|
System.err.println("===================================================================");
|
||||||
System.err.println("You must login using 'nomulus login' prior to running this command.");
|
System.err.println("You must login using 'nomulus login' prior to running this command.");
|
||||||
System.err.println("===================================================================");
|
System.err.println("===================================================================");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
} else {
|
} else {
|
||||||
throw ex;
|
// See if this looks like the error we get when there's another instance of nomulus tool
|
||||||
|
// running against SQL and give the user some additional guidance if so.
|
||||||
|
Optional<Throwable> psqlException =
|
||||||
|
Throwables.getCausalChain(e).stream()
|
||||||
|
.filter(x -> x instanceof PSQLException)
|
||||||
|
.findFirst();
|
||||||
|
if (psqlException.isPresent() && psqlException.get().getMessage().contains("google:5432")) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("===================================================================");
|
||||||
|
System.err.println(
|
||||||
|
"This error is likely the result of having another instance of\n"
|
||||||
|
+ "nomulus running at the same time. Check your system, shut down\n"
|
||||||
|
+ "the other instance, and try again.");
|
||||||
|
System.err.println("===================================================================");
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue