-
Notifications
You must be signed in to change notification settings - Fork 5
/
SourceException.java
43 lines (35 loc) · 1.18 KB
/
SourceException.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.exceptions;
import java.util.List;
/**
* Exception that should be used whenever an error occurs in a instance of a {@link
* edu.ie3.datamodel.io.source.DataSource}
*
* @version 0.1
* @since 19.03.20
*/
public class SourceException extends Exception {
private static final long serialVersionUID = -1861732230033172395L;
public SourceException(final String message, final Throwable cause) {
super(message, cause);
}
public SourceException(final Throwable cause) {
super(cause);
}
public SourceException(final String message) {
super(message);
}
public SourceException(String message, List<? extends Exception> exceptions) {
super(message + " " + addMessages(exceptions), exceptions.get(0));
}
private static String addMessages(List<? extends Exception> exceptions) {
Exception firstInList = exceptions.remove(0);
return exceptions.stream()
.map(Throwable::getMessage)
.reduce(firstInList.getMessage(), (a, b) -> a + ", " + b);
}
}