1
1
package de .komoot .photon ;
2
2
3
- import de .komoot .photon .DatabaseProperties ;
4
- import de .komoot .photon .Importer ;
5
- import de .komoot .photon .Updater ;
6
3
import de .komoot .photon .searcher .StructuredSearchHandler ;
7
4
import de .komoot .photon .searcher .ReverseHandler ;
8
5
import de .komoot .photon .searcher .SearchHandler ;
@@ -65,7 +62,7 @@ public Server(String mainDirectory) {
65
62
try {
66
63
setupDirectories (new File (mainDirectory ).toURI ().toURL ());
67
64
} catch (Exception e ) {
68
- throw new RuntimeException ("Can't create directories: " + mainDirectory , e );
65
+ throw new UsageException ("Can't create directories: " + mainDirectory + ": " + e . getMessage () );
69
66
}
70
67
}
71
68
@@ -107,7 +104,7 @@ public Server start(String clusterName, String[] transportAddresses) {
107
104
esClient = esNode .client ();
108
105
109
106
} catch (NodeValidationException e ) {
110
- throw new RuntimeException ("Error while starting elasticsearch server" , e );
107
+ throw new UsageException ("Error while starting elasticsearch server: " + e . getMessage () );
111
108
}
112
109
113
110
}
@@ -133,7 +130,7 @@ public void shutdown() {
133
130
134
131
esClient .close ();
135
132
} catch (IOException e ) {
136
- throw new RuntimeException ("Error during elasticsearch server shutdown" , e );
133
+ LOGGER . info ("Error during elasticsearch server shutdown" , e );
137
134
}
138
135
}
139
136
@@ -260,13 +257,13 @@ public void loadFromDatabase(DatabaseProperties dbProperties) {
260
257
Map <String , String > properties = (Map <String , String >) response .getSource ().get (BASE_FIELD );
261
258
262
259
if (properties == null ) {
263
- throw new RuntimeException ("Found database properties but no '" + BASE_FIELD +"' field. Database corrupt?" );
260
+ throw new UsageException ("Found database properties but no '" + BASE_FIELD +"' field. Database corrupt?" );
264
261
}
265
262
266
263
String version = properties .getOrDefault (FIELD_VERSION , "" );
267
264
if (!DatabaseProperties .DATABASE_VERSION .equals (version )) {
268
265
LOGGER .error ("Database has incompatible version '{}'. Expected: {}" , version , DatabaseProperties .DATABASE_VERSION );
269
- throw new RuntimeException ("Incompatible database." );
266
+ throw new UsageException ("Incompatible database." );
270
267
}
271
268
272
269
String langString = properties .get (FIELD_LANGUAGES );
0 commit comments