1
0
mirror of https://github.com/google/nomulus synced 2026-07-19 22:42:23 +00:00

Include a better error message to debug nomulus tool not working (#2275)

Failures to initialize the tool transaction manager seem to often be caused by
stale local credentials.
This commit is contained in:
Ben McIlwain
2024-01-24 13:08:33 -05:00
committed by GitHub
parent 818944317f
commit 64f5971275
@@ -23,6 +23,7 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import com.google.common.base.Ascii;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
@@ -218,12 +219,21 @@ final class RegistryCli implements CommandRunner {
// Reset the JPA transaction manager after every command to avoid a situation where a test can
// interfere with other tests
JpaTransactionManager cachedJpaTm = tm();
TransactionManagerFactory.setJpaTm(() -> component.nomulusToolJpaTransactionManager().get());
TransactionManagerFactory.setReplicaJpaTm(
() -> component.nomulusToolReplicaJpaTransactionManager().get());
command.run();
TransactionManagerFactory.setJpaTm(() -> cachedJpaTm);
try {
JpaTransactionManager cachedJpaTm = tm();
TransactionManagerFactory.setJpaTm(() -> component.nomulusToolJpaTransactionManager().get());
TransactionManagerFactory.setReplicaJpaTm(
() -> component.nomulusToolReplicaJpaTransactionManager().get());
command.run();
TransactionManagerFactory.setJpaTm(() -> cachedJpaTm);
} catch (Exception e) {
String env = Ascii.toLowerCase(environment.name());
System.err.printf(
"Could not get tool transaction manager; try running nomulus -e %s logout "
+ "and then nomulus -e %s login.\n",
env, env);
throw e;
}
}
void setEnvironment(RegistryToolEnvironment environment) {