Skip to content

Commit 158dd41

Browse files
committed
add history to rethrown exceptions
1 parent 64198e1 commit 158dd41

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/datadoghq/workshops/samplevulnerablejavaapp/DomainTestService.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ public String testDomain(String domainName) throws DomainTestException {
3535
}
3636
return new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
3737
} catch (IOException e) {
38-
throw new UnableToTestDomainException("Internal error while testing domain: " + e.getMessage());
38+
DomainTestException dte = new UnableToTestDomainException("Internal error while testing domain: " + e.getMessage());
39+
dte.initCause(e);
40+
throw dte;
3941
} catch (InterruptedException e) {
40-
throw new UnableToTestDomainException("Timed out pinging domain");
42+
DomainTestException dte = new UnableToTestDomainException("Timed out pinging domain");
43+
dte.initCause(e);
44+
throw dte;
4145
}
4246
}
4347

0 commit comments

Comments
 (0)