Replace IOException with JacksonException in catch clauses

Apache 2.0

In Jackson 3, ObjectMapper and related classes no longer throw IOException. This recipe replaces catch (IOException e) with catch (JacksonException e) when the try block contains Jackson API calls. When the try block also contains non-Jackson code that throws IOException, such as the implicit close() of a try-with-resources resource, the catch is changed to a multi-catch catch (JacksonException | IOException e). Where the caught exception is passed on as an IOException, for instance to new UncheckedIOException(e), it is wrapped in a new IOException(e); such catches are left alone when the try block also throws IOException from non-Jackson code. Likewise, IOException is removed from Lombok's @SneakyThrows on methods whose only IOException source is Jackson.

org.openrewrite.java.jackson.IOExceptionToJacksonException
mod run . --recipe=org.openrewrite.java.jackson.IOExceptionToJacksonException

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.