Skip to content

Commit 4c9d814

Browse files
committed
Adds a setter for logPrefix in exception catcher
The `logPrefix` in `ObjectExceptionCatcher` should not only be settable via the constructor but through a setter method as well. Additionally, this commit removes some superfluous white space.
1 parent 5ab3705 commit 4c9d814

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/main/java/org/culturegraph/mf/stream/pipe/ObjectExceptionCatcher.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929

3030
/**
3131
* Wraps the call to the process method of the downstream module
32-
* in a try catch block with Exception as the catch-block's
33-
* argument type. This module is supposed to stop any exception
34-
* from downstream modules to travel further upstream. If an
35-
* exception is caught, a log message with log level "error" is
36-
* written.
37-
*
32+
* in a try catch block with Exception as the catch-block's
33+
* argument type. This module is supposed to stop any exception
34+
* from downstream modules to travel further upstream. If an
35+
* exception is caught, a log message with log level "error" is
36+
* written.
37+
*
3838
* @param <T> object type
39-
*
39+
*
4040
* @author Christoph Böhme
4141
*/
4242
@Description("passes objects through and catches exceptions.")
@@ -47,19 +47,26 @@ public final class ObjectExceptionCatcher<T> extends
4747

4848
private static final Logger LOG = LoggerFactory.getLogger(ObjectExceptionCatcher.class);
4949

50-
private final String logPrefix;
51-
50+
private String logPrefix;
5251
private boolean logStackTrace;
5352

5453
public ObjectExceptionCatcher() {
5554
this("");
5655
}
57-
56+
5857
public ObjectExceptionCatcher(final String logPrefix) {
5958
super();
6059
this.logPrefix = logPrefix;
6160
}
6261

62+
public void setLogPrefix(final String logPrefix) {
63+
this.logPrefix = logPrefix;
64+
}
65+
66+
public String getLogPrefix() {
67+
return logPrefix;
68+
}
69+
6370
public void setLogStackTrace(final boolean logStackTrace) {
6471
this.logStackTrace = logStackTrace;
6572
}
@@ -72,7 +79,7 @@ public boolean isLogStackTrace() {
7279
public void process(final T obj) {
7380
try {
7481
getReceiver().process(obj);
75-
} catch(final Exception e) {
82+
} catch(final Exception e) {
7683
// NO CHECKSTYLE IllegalCatch FOR -1 LINES:
7784
// This module is supposed to intercept _all_ exceptions
7885
// thrown by downstream modules. Hence, we have to catch

0 commit comments

Comments
 (0)