ExceptionHandling

object ExceptionHandling extends AnyRef

Examples of how to provide custom error handlers when using Scala IO.

By default a ScalaIOException is thrown when an error occurs accessing or closing a resource. The following examples illustrate how this default behaviour can be customized for a specific application.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ExceptionHandling
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  7. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  9. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef → Any
  12. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  13. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  14. def logClosingError : Unit

    Add a custom error handler that in the case of an error during closing simply logs the error and returns the result that was calculated before closing.

  15. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  16. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  17. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  18. def returnDefaultValueOnFailure : Unit

    Illustrate how a default value can be returned if an error occurs.

    Illustrate how a default value can be returned if an error occurs.

    In the example below it is known that only a single request will be made, and the type of result is also known so a default value can be provided.

    This pattern can be quite tricky because the internals of how Scala-IO works needs to be known. For example if providing a default for string then one must know that bytes must be returned as the default rather than a string.

    Also if the scala-io implementation changes the code could break. Defaults work better when working with acquireAndGet or acquireFor

  19. def returnDefaultValueWithFunctionMatching : Unit

    Illustrate an alternate (and advanced) pattern where in the case of an exception a default value is returned by the error handler.

    Illustrate an alternate (and advanced) pattern where in the case of an exception a default value is returned by the error handler.

    This is not a particularly common pattern of usage, but illustrates one of the more advanced possibilities

  20. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  21. def toString (): String

    Definition Classes
    AnyRef → Any
  22. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  24. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any