Very interesting question!

Given that you don't know what to do with the checked exception means that
the checked exception probably shouldn't be checked in the first place
(e.g. SQLException, IOException, etc.). The common approach here is to wrap
it in a runtime exception (for SQLException, I suggest jOOQ's
DataAccessException).

A bit less common is to "sneaky throw" the checked exception again:
https://blog.jooq.org/2012/09/14/throw-checked-exceptions-like-runtime-exceptions-in-java/

You could also use jOOλ's Unchecked for this, possibly:
https://github.com/jOOQ/jOOL/blob/master/src/main/java/org/jooq/lambda/Unchecked.java

If you know you need to catch the specific checked exception somewhere
outside of that mapper, then you'll have to be creative. But chances are
high, you don't.

I hope this helps,
Lukas

2016-07-21 17:53 GMT+02:00 Denis Miorandi <[email protected]>:

> actually I use jooq mapper like this, but I don't know how to manage
> checked exception inside map method like throws.
> I know this is not stricly a jooq stuff, but: any suggestions to do it in
> a smart way?
>
> .fetchOne()
> .map(new RecordMapper<Record, MyType>() {
> @Override
>         public MyType map(Record record) *throws HERE???* {
>                 ....
> *                something that throw Exception *
>                 .....
>         }
> }
>
>
> Actually I've seen something similar
>
>
>    - https://github.com/fge/throwing-lambdas
>    - https://github.com/JeffreyFalgout/ThrowingStream
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to