Decorative site banner
Project icon

com.io7m.jdeferthrow

  • About
  • Releases
  • Manual
  • Sources
  • License
  • Issues
Maven Central Version Maven Snapshot Code Coverage

jdeferthrow


The jdeferthrow package implements a trivial API for combining multiple exceptions over a series of statements.

Usage


final var tracker = new ExceptionTracker<IOException>(); try { doIO1(); } catch (IOException e1) { tracker.addException(e1); } try { doIO2(); } catch (IOException e2) { tracker.addException(e2); } try { doIO3(); } catch (IOException e3) { tracker.addException(e3); } tracker.throwIfNecessary();

The above code will execute doIO1, doIO2, and doIO3, catching each exception if any are raised. The throwIfNecessary method will throw whichever of e1, e2, or e3 was caught first, with either of the other two exceptions added to the thrown exception as a suppressed exception.

Concretely, if all of doIO1, doIO2, and doIO3 throw exceptions, the throwIfNecessary method will throw e1 with e2 and e3 added to e1 as suppressed exceptions.

This effectively allows for accumulating exceptions over a range of statements and then throwing an exception at the end that contains all of the exceptions that were thrown.

If addException was not called, throwIfNecessary does nothing.

Releases & Development Snapshots


Releases


You can subscribe to the atom feed to be notified of project releases.

The most recently released version of the package is 1.3.0.

1.3.0 Release (2024-05-05Z)

  • Update ch.qos.logback:logback-classic:1.4.14 → 1.5.6.
  • Update org.slf4j:slf4j-api:2.0.10 → 2.0.13.
  • Update junit.version:5.10.1 → 5.10.2.

The compiled artifacts for the release (and all previous releases) are available on Maven Central.

Maven Modules


<dependency> <group>com.io7m.jdeferthrow</group> <artifactId>com.io7m.jdeferthrow.core</artifactId> <version>1.3.0</version> </dependency><dependency> <group>com.io7m.jdeferthrow</group> <artifactId>com.io7m.jdeferthrow.tests</artifactId> <version>1.3.0</version> </dependency>

Previous Releases


The changelogs for the most recent previous releases are as follows:

1.2.0 Release (2022-06-30Z)

  • The project now exports named JPMS modules instead of just automatic modules.

1.1.0 Release (2021-05-28Z)

  • Add catching()

1.0.0 Release (2021-05-04Z)

Development Snapshots


At the time of writing, the current unstable development version of the package is 1.4.0-SNAPSHOT.

Development snapshots may be available in the Central Portal Snapshots repository. Snapshots are published to this repository every time the project is built by the project's continuous integration system, but snapshots do expire after around ninety days and so may or may not be available depending on when a build of the package was last triggered.

Manual


This project does not have any user manuals or other documentation beyond what might be present on the page above.

Sources


This project uses Git to manage source code.

Repository: https://www.github.com/io7m-com/jdeferthrow

$ git clone --recursive https://www.github.com/io7m-com/jdeferthrow

Issues


This project uses GitHub Issues to track issues.

License


Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Last Updated 2025-08-09T14:56:34Z