@@ -136,14 +136,12 @@ public Coderun(Path configFilePath, @Nullable Path scriptPath) {
136
136
public Coderun (Path configFilePath , @ Nullable Path scriptPath , @ Nullable String registryToken ) {
137
137
YamlReader yamlReader = new YamlFactory ().yamlReader ();
138
138
if (!new File (configFilePath .toString ()).isFile ()) {
139
- String msg = "Coderun -- configFilePath argument must be a Path to a config file." ;
140
- logger .error (msg );
141
- throw (new IllegalArgumentException (msg ));
139
+ throw (new IllegalArgumentException (
140
+ "Coderun -- configFilePath argument must be a Path to a config file." ));
142
141
}
143
142
if (scriptPath != null && !new File (scriptPath .toString ()).isFile ()) {
144
- String msg = "Coderun -- scriptPath argument must be a Path to a script file." ;
145
- logger .error (msg );
146
- throw (new IllegalArgumentException (msg ));
143
+ throw (new IllegalArgumentException (
144
+ "Coderun -- scriptPath argument must be a Path to a script file." ));
147
145
}
148
146
149
147
this .coderuns_txt = configFilePath .getParent ().resolve ("coderuns.txt" );
@@ -160,9 +158,8 @@ public Coderun(Path configFilePath, @Nullable Path scriptPath, @Nullable String
160
158
if (Files .isReadable (Path .of (filename ))) {
161
159
registryToken = new FileReader ().read (filename );
162
160
} else {
163
- String msg = "No registry token given. Giving up." ;
164
- logger .error (msg );
165
- throw (new IllegalActionException (msg ));
161
+ throw (new IllegalActionException (
162
+ "No registry token given. Giving up. (Token can be given in the config or in the Coderun constructor)" ));
166
163
}
167
164
}
168
165
}
@@ -200,10 +197,8 @@ public Coderun(Path configFilePath, @Nullable Path scriptPath, @Nullable String
200
197
if (config .run_metadata ().script_path ().isPresent ()) {
201
198
scriptPath = Path .of (config .run_metadata ().script_path ().get ());
202
199
} else {
203
- String msg =
204
- "Coderun() -- Script path must be given either in constructor args or in config." ;
205
- logger .error (msg );
206
- throw (new ConfigException (msg ));
200
+ throw (new ConfigException (
201
+ "Coderun() -- Script path must be given either in constructor args or in config." ));
207
202
}
208
203
}
209
204
this .config_storage_location =
@@ -246,9 +241,8 @@ private void prepare_code_run() {
246
241
try {
247
242
remote_repo_url = new URL (remote_repo );
248
243
} catch (MalformedURLException e ) {
249
- String msg = "Remote repo must be a valid URL; (" + remote_repo + " isn't)" ;
250
- logger .error (msg );
251
- throw (new ConfigException (msg , e ));
244
+ throw (new ConfigException (
245
+ "Remote repo must be a valid URL; (" + remote_repo + " isn't)" , e ));
252
246
}
253
247
254
248
this .codeRepo =
@@ -330,10 +324,8 @@ public Data_product_read get_dp_for_read(String dataProduct_name) {
330
324
if (dp_info_map .containsKey (dataProduct_name )) {
331
325
// I could of course refuse to serve up the same DP twice, but let's be friendly.
332
326
if (dp_info_map .get (dataProduct_name ).getClass () != Data_product_read .class ) {
333
- String msg =
334
- "You are trying to open the same data product twice in the same coderun, first for write and then for read. Please don't." ;
335
- logger .error (msg );
336
- throw (new IllegalActionException (msg ));
327
+ throw (new IllegalActionException (
328
+ "You are trying to open the same data product twice in the same coderun, first for write and then for read. Please don't." ));
337
329
}
338
330
return (Data_product_read ) dp_info_map .get (dataProduct_name );
339
331
}
@@ -353,16 +345,12 @@ public Data_product_write get_dp_for_write(String dataProduct_name, String exten
353
345
if (dp_info_map .containsKey (dataProduct_name )) {
354
346
// I could of course refuse to serve up the same DP twice, but let's be friendly.
355
347
if (dp_info_map .get (dataProduct_name ).getClass () != Data_product_write .class ) {
356
- String msg =
357
- "You are trying to open the same data product twice in the same coderun, first for read and then for write. Please don't." ;
358
- logger .error (msg );
359
- throw (new IllegalActionException (msg ));
348
+ throw (new IllegalActionException (
349
+ "You are trying to open the same data product twice in the same coderun, first for read and then for write. Please don't." ));
360
350
}
361
351
if (!dp_info_map .get (dataProduct_name ).extension .equals (extension )) {
362
- String msg =
363
- "You are trying to open the same data product using two different file types. Please don't." ;
364
- logger .error (msg );
365
- throw (new IllegalActionException (msg ));
352
+ throw (new IllegalActionException (
353
+ "You are trying to open the same data product using two different file types. Please don't." ));
366
354
}
367
355
return (Data_product_write ) dp_info_map .get (dataProduct_name );
368
356
}
@@ -381,10 +369,8 @@ public Data_product_write get_dp_for_write(String dataProduct_name) {
381
369
if (dp_info_map .containsKey (dataProduct_name )) {
382
370
// I could of course refuse to serve up the same DP twice, but let's be friendly.
383
371
if (dp_info_map .get (dataProduct_name ).getClass () != Data_product_write .class ) {
384
- String msg =
385
- "You are trying to open the same data product twice in the same coderun, first for read and then for write. Please don't." ;
386
- logger .error (msg );
387
- throw (new IllegalActionException (msg ));
372
+ throw (new IllegalActionException (
373
+ "You are trying to open the same data product twice in the same coderun, first for read and then for write. Please don't." ));
388
374
}
389
375
return (Data_product_write ) dp_info_map .get (dataProduct_name );
390
376
}
@@ -445,9 +431,8 @@ public void close() {
445
431
dp_info_map .forEach ((key , value ) -> value .close ());
446
432
RegistryCode_run coderun = (RegistryCode_run ) restClient .post (this .registryCode_run );
447
433
if (coderun == null ) {
448
- String msg = "Failed to create Code_run in registry: " + this .registryCode_run ;
449
- logger .error (msg );
450
- throw (new RegistryException (msg ));
434
+ throw (new RegistryException (
435
+ "Failed to create Code_run in registry: " + this .registryCode_run ));
451
436
}
452
437
this .register_issues ();
453
438
this .append_code_run_uuid (coderun .getUuid ());
0 commit comments