Package org.apache.sis.image

# Interface ErrorHandler

public interface ErrorHandler
Action to perform when errors occurred while reading or writing some tiles in an image. The most typical actions are throwing an exception or logging a warning.

Since:
  1.1

Defined in the `sis-feature` module

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `ErrorHandler​.Report`
  Information about errors that occurred while reading or writing tiles in an image.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final ErrorHandler`
  `LOG`
  Exceptions are wrapped in a `LogRecord` and logged, usually at `Level​.WARNING`.
  `static final ErrorHandler`
  `THROW`
  Exceptions are wrapped in an `ImagingOpException` and thrown.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `handle(ErrorHandler​.Report details)`
  Invoked after errors occurred in one or many tiles.

- ## Field Details

  - ### THROW

    static final ErrorHandler THROW
    Exceptions are wrapped in an `ImagingOpException` and thrown. In such case, no result is available. This is the default handler.

  - ### LOG

    static final ErrorHandler LOG
    Exceptions are wrapped in a `LogRecord` and logged, usually at `Level​.WARNING`. Only one log record is created for all tiles that failed for the same operation on the same image. A partial result may be available.

    Users are encouraged to use `THROW` or to specify their own `ErrorHandler` instead of using this error action, because not everyone read logging records.

- ## Method Details

  - ### handle

    void handle(ErrorHandler.Report details)
    Invoked after errors occurred in one or many tiles. This method may be invoked an arbitrary time after the error occurred, and may aggregate errors that occurred in more than one tile.

    #### Multi-threading

    If the image processing was splitted between many worker threads, this method may be invoked from any of those threads. However the invocation should happen after all threads terminated, either successfully or with an error reported in `details`.
    Parameters:
      `details` - information about the first error. If more than one error occurred, the other errors are reported as suppressed exceptions.