File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
src/main/java/ch/powerunit/extensions/exceptions Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff 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 () {
Original file line number Diff line number Diff line change 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>? extends Exception< 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 *
You can’t perform that action at this time.
0 commit comments