Class AsyncError

Inheritance Relationships

Base Type

Class Documentation

class AsyncError : public zim::CreatorError

Exception thrown in the main thread when another exception has been thrown in another worker thread.

Creator uses different worker threads to do background work. If an exception is thrown in one of this threads, it is catched and “rethrown” in the main thread as soon as possible with a AsyncError.

AsyncError contains the original exception. You can rethrow the original exception using rethrow:

try {
  creator->addStuff(...);
} catch (const zim::AsyncError& e) {
  // An exception has been thrown in a worker thread
  try {
    e.rethrow();
  } catch (const std::exception& original_exception) {
    // original_exception is the exception thrown in the worker thread
    ...
  }
}

Public Functions

inline explicit AsyncError(const std::exception_ptr exception)
inline void rethrow() const