Method
wrap
(Function<T, R> a, Errors error, R def, Class convertReturn)
Source from the content-addressed store, hash-verified
| 64 | } |
| 65 | |
| 66 | public static <T, R> Function<T, R> wrap(Function<T, R> a, Errors error, R def, Class convertReturn) { |
| 67 | return x -> { |
| 68 | try { |
| 69 | Object q = a.apply(x); |
| 70 | |
| 71 | if (convertReturn != null) q = Conversions.convert(q, convertReturn); |
| 72 | |
| 73 | |
| 74 | // if (q instanceof Undefined) return null; |
| 75 | |
| 76 | return (R) q; |
| 77 | } catch (Throwable t) { |
| 78 | t.printStackTrace(); |
| 79 | error.add(t, a); |
| 80 | return def; |
| 81 | } |
| 82 | }; |
| 83 | } |
| 84 | |
| 85 | public static <T> Consumer<T> wrap(Consumer<T> a, Errors error) { |
| 86 | return x -> { |
Tested by
no test coverage detected