mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 21:18:58 +00:00
Throw a custom exception when WMSA_HOME isn't found
This commit is contained in:
parent
32a6735d03
commit
9455100907
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user