Skip to content

Commit 985d8d1

Browse files
committed
absolute normalized paths in error logs
1 parent 728cb8f commit 985d8d1

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

dsf-tools/dsf-tools-test-data-generator/src/main/java/dev/dsf/tools/generator/CertificateGenerator.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ private void writePrivateKeyEncrypted(Path privateKeyFile, PrivateKey privateKey
177177
}
178178
catch (IOException | OperatorCreationException e)
179179
{
180-
logger.error("Error while writing encrypted private-key to {}", privateKeyFile.toString(), e);
180+
logger.error("Error while writing encrypted private-key to {}",
181+
privateKeyFile.toAbsolutePath().normalize().toString(), e);
181182
throw new RuntimeException(e);
182183
}
183184
}
@@ -190,7 +191,8 @@ private void writePrivateKeyNotEncrypted(Path privateKeyFile, PrivateKey private
190191
}
191192
catch (IOException | OperatorCreationException e)
192193
{
193-
logger.error("Error while writing not-encrypted private-key to {}", privateKeyFile.toString(), e);
194+
logger.error("Error while writing not-encrypted private-key to {}",
195+
privateKeyFile.toAbsolutePath().normalize().toString(), e);
194196
throw new RuntimeException(e);
195197
}
196198
}
@@ -203,7 +205,8 @@ private void writeCertificate(Path certificateFile, X509Certificate certificate)
203205
}
204206
catch (CertificateEncodingException | IllegalStateException | IOException e)
205207
{
206-
logger.error("Error while writing certificate to {}", certificateFile.toString(), e);
208+
logger.error("Error while writing certificate to {}",
209+
certificateFile.toAbsolutePath().normalize().toString(), e);
207210
throw new RuntimeException(e);
208211
}
209212
}
@@ -216,7 +219,8 @@ private PrivateKey readPrivatekey(Path privateKeyFile)
216219
}
217220
catch (IOException | PKCSException e)
218221
{
219-
logger.error("Error while reading private-key from {}", privateKeyFile.toString(), e);
222+
logger.error("Error while reading private-key from {}",
223+
privateKeyFile.toAbsolutePath().normalize().toString(), e);
220224
throw new RuntimeException(e);
221225
}
222226
}
@@ -229,7 +233,8 @@ private X509Certificate readCertificate(Path certFile)
229233
}
230234
catch (CertificateException | IOException e)
231235
{
232-
logger.error("Error while reading certificate from {}", certFile.toString(), e);
236+
logger.error("Error while reading certificate from {}", certFile.toAbsolutePath().normalize().toString(),
237+
e);
233238
throw new RuntimeException(e);
234239
}
235240
}
@@ -251,7 +256,8 @@ public void writeThumbprints()
251256
}
252257
catch (IOException e)
253258
{
254-
logger.error("Error while writing certificate thumbprints file to {}", thumbprintsFile.toString(), e);
259+
logger.error("Error while writing certificate thumbprints file to {}",
260+
thumbprintsFile.toAbsolutePath().normalize().toString(), e);
255261
throw new RuntimeException(e);
256262
}
257263
}
@@ -364,7 +370,8 @@ private void writeCertificateRequest(Path certificateRequestFile, JcaPKCS10Certi
364370
}
365371
catch (IOException e)
366372
{
367-
logger.error("Error while reading certificate-request from {}", certificateRequestFile.toString(), e);
373+
logger.error("Error while reading certificate-request from {}",
374+
certificateRequestFile.toAbsolutePath().normalize().toString(), e);
368375
throw new RuntimeException(e);
369376
}
370377
}
@@ -377,7 +384,8 @@ private JcaPKCS10CertificationRequest readCertificateRequest(Path certificateReq
377384
}
378385
catch (NoSuchAlgorithmException | InvalidKeySpecException | IOException e)
379386
{
380-
logger.error("Error while reading certificate-request from {}", certificateRequestFile.toString(), e);
387+
logger.error("Error while reading certificate-request from {}",
388+
certificateRequestFile.toAbsolutePath().normalize().toString(), e);
381389
throw new RuntimeException(e);
382390
}
383391
}
@@ -450,7 +458,8 @@ private Path createFolderIfNotExists(Path file)
450458
}
451459
catch (IOException e)
452460
{
453-
logger.error("Error while creating directories {}", file.getParent().toString(), e);
461+
logger.error("Error while creating directories {}",
462+
file.getParent().toAbsolutePath().normalize().toString(), e);
454463
throw new RuntimeException(e);
455464
}
456465

@@ -694,7 +703,8 @@ private void writeCertificates(Path certificateFile, X509Certificate... certific
694703
}
695704
catch (CertificateEncodingException | IllegalStateException | IOException e)
696705
{
697-
logger.error("Error while writing certificate to {}", certificateFile.toString(), e);
706+
logger.error("Error while writing certificate to {}",
707+
certificateFile.toAbsolutePath().normalize().toString(), e);
698708
throw new RuntimeException(e);
699709
}
700710
}
@@ -738,7 +748,7 @@ private void writeKeyStore(Path file, KeyStore keyStore)
738748
}
739749
catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException e)
740750
{
741-
logger.error("Error while writing keystore file to {}", file.toString(), e);
751+
logger.error("Error while writing keystore file to {}", file.toAbsolutePath().normalize().toString(), e);
742752
throw new RuntimeException(e);
743753
}
744754
}

0 commit comments

Comments
 (0)