public function dispatch($eventStr)
    {
        try {
            // decode as array because data proprty, which has unknown structure (only known by handler),
            // must remain array after mapping to event
            $arr = MapperUtil::jsonDecode($eventStr, true);
            $event = MapperUtil::map($arr, Event::class);
        } catch (Exception $e) {
            throw  new ClientError("Invalid event JSON", $e);
        }

        foreach ($this->handlerMap as $callback) {
            try {
                if ($callback->handle($event)) {
                    return;
                }
            } catch (Exception $e) {
                if (!$e instanceof AbstractError) {
                    throw  new ClientError("Unknown error processing the event", $e);
                } else {
                    throw $e;
                }
            }
        }
    }