Skip to content

Commit fce0627

Browse files
committed
Issue #66 - Add documentation
1 parent 5ed2619 commit fce0627

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/main/java/ch/powerunit/extensions/exceptions/ExceptionMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private boolean accept(Exception e) {
115115
* This method is used when ExceptionMapper are registered as default Mapper to
116116
* defines the right order to select then.
117117
*
118-
* @return a ordering key, by default 0.
118+
* @return an ordering key, by default 0.
119119
* @since 2.2.0
120120
*/
121121
default int order() {

src/main/java/ch/powerunit/extensions/exceptions/package-info.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,41 @@
5656
* Function<String, Optional<String>> functionWithOptionalResult =
5757
* FunctionWithException.lifted(fonctionThrowingException);
5858
* </pre>
59+
*
60+
* <h2>Exception Mapping</h2>
61+
*
62+
* By default, the exception are transformed into a {@code RuntimeException}
63+
* using the {@link ch.powerunit.extensions.exceptions.WrappedException}. This
64+
* behaviour can be changed locally (second argument of the {@code unchecked}
65+
* methods) or globally (by registering default {@code ExceptionMapper}.
66+
*
67+
* To do the global configuration, it is required first to create the
68+
* {@code ExceptionMapper}:
69+
*
70+
* <pre>
71+
* public class MyExceptionMapper implements ExceptionMapper {
72+
* public RuntimeException apply(Exception e) {
73+
* //TODO
74+
* }
75+
* public Class&gt;? extends Exception&lt; targetException() {
76+
* return //TODO;
77+
* }
78+
* // Optional, to define the order between the ExceptionMapper
79+
* public int order() {
80+
* return 100;
81+
* }
82+
* }
83+
* </pre>
84+
*
85+
* Then, the {@code ExceptionMapper} must be registered :
86+
*
87+
* <pre>
88+
* module XXX {
89+
* requires powerunit.exceptions;
90+
* provides ch.powerunit.extensions.exceptions.ExceptionMapper
91+
* with ....MyExceptionMapper;
92+
* }
93+
* </pre>
5994
*
6095
* @see java.util.function
6196
*

0 commit comments

Comments
 (0)