diff --git a/code/common/config/src/main/java/nu/marginalia/WmsaHome.java b/code/common/config/src/main/java/nu/marginalia/WmsaHome.java index b63761b0..ae09940e 100644 --- a/code/common/config/src/main/java/nu/marginalia/WmsaHome.java +++ b/code/common/config/src/main/java/nu/marginalia/WmsaHome.java @@ -1,6 +1,7 @@ package nu.marginalia; +import nu.marginalia.service.ServiceHomeNotConfiguredException; import nu.marginalia.service.descriptor.HostsFile; import java.io.FileNotFoundException; @@ -30,12 +31,12 @@ public class WmsaHome { var ret = Path.of(retStr); if (!Files.isDirectory(ret)) { - throw new IllegalStateException("Could not find $WMSA_HOME, either set environment variable or ensure " + retStr + " exists"); + throw new ServiceHomeNotConfiguredException("Could not find $WMSA_HOME, either set environment variable or ensure " + retStr + " exists"); } if (!Files.isDirectory(ret.resolve("model"))) { - throw new IllegalStateException("You need to run 'run/setup.sh' to download models to run/ before this will work!"); + throw new ServiceHomeNotConfiguredException("You need to run 'run/setup.sh' to download models to run/ before this will work!"); } return ret; diff --git a/code/common/service-discovery/src/main/java/nu/marginalia/service/ServiceHomeNotConfiguredException.java b/code/common/service-discovery/src/main/java/nu/marginalia/service/ServiceHomeNotConfiguredException.java new file mode 100644 index 00000000..181428e1 --- /dev/null +++ b/code/common/service-discovery/src/main/java/nu/marginalia/service/ServiceHomeNotConfiguredException.java @@ -0,0 +1,11 @@ +package nu.marginalia.service; + +public class ServiceHomeNotConfiguredException extends RuntimeException { + + public ServiceHomeNotConfiguredException() { + super("WMSA_HOME environment variable not set"); + } + public ServiceHomeNotConfiguredException(String message) { + super(message); + } +} diff --git a/code/common/service/src/main/java/nu/marginalia/service/module/DatabaseModule.java b/code/common/service/src/main/java/nu/marginalia/service/module/DatabaseModule.java index 8a51d141..e3d660ad 100644 --- a/code/common/service/src/main/java/nu/marginalia/service/module/DatabaseModule.java +++ b/code/common/service/src/main/java/nu/marginalia/service/module/DatabaseModule.java @@ -6,6 +6,7 @@ import com.google.inject.Singleton; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import lombok.SneakyThrows; +import nu.marginalia.service.ServiceHomeNotConfiguredException; import org.mariadb.jdbc.Driver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,7 +61,7 @@ public class DatabaseModule extends AbstractModule { var ret = Path.of(retStr); if (!Files.isDirectory(ret)) { - throw new IllegalStateException("Could not find WMSA_HOME, either set environment variable or ensure /var/lib/wmsa exists"); + throw new ServiceHomeNotConfiguredException("Could not find WMSA_HOME, either set environment variable or ensure /var/lib/wmsa exists"); } return ret; }