Packages

package plus

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait OnTryFinally extends AnyRef

    A mix-in trait which provides an onTry { ... } onFinally { ... } and onTry { ... } onThrowable { ... } statement.

    A mix-in trait which provides an onTry { ... } onFinally { ... } and onTry { ... } onThrowable { ... } statement. These statements chain exceptions from both code blocks via Throwable.addSuppressed(Throwable).

  2. trait ResourceLoan extends AnyRef

    A mix-in trait which provides Java's basic "try-with-resources" statement.

    A mix-in trait which provides Java's basic "try-with-resources" statement.

    Usage example:

    import net.java.truecommons3.shed.ResourceLoan_
    val out: OutputStream = ...
    loan(new PrintWriter(out)) to { w: PrintWriter => w.println("Hello world!") }

    In this example, w.close() is guaranteed to get called even if the to-function terminates with a Throwable.

    In general, if the to-function throws a throwable t1 and the AutoCloseable.close() method throws another throwable t2, then the throwable t2 gets added to the throwable t1 using t1.addSuppressed(t2).

    See also

    The Java Language Specification: Java SE 7 Edition: 14.20.3.1 Basic try-with-resources

Value Members

  1. object OnTryFinally extends OnTryFinally

    An object which provides an onTry { ... } onFinally { ... } and onTry { ... } onThrowable { ... } statement.

    An object which provides an onTry { ... } onFinally { ... } and onTry { ... } onThrowable { ... } statement. These statements chain exceptions from both code blocks via Throwable.addSuppressed(Throwable).

  2. object ResourceLoan extends ResourceLoan

    An object which provides Java's basic "try-with-resources" statement.

    An object which provides Java's basic "try-with-resources" statement.

    Usage example:

    import net.java.truecommons3.shed.ResourceLoan_
    val out: OutputStream = ...
    loan(new PrintWriter(out)) to { w: PrintWriter => w.println("Hello world!") }

    In this example, w.close() is guaranteed to get called even if the to-function terminates with a Throwable.

    In general, if the to-function throws a throwable t1 and the AutoCloseable.close() method throws another throwable t2, then the throwable t2 gets added to the throwable t1 using t1.addSuppressed(t2).

    See also

    The Java Language Specification: Java SE 7 Edition: 14.20.3.1 Basic try-with-resources

Ungrouped