public function executeWith($callable, $handler = null)
    {
        $handlers = $this->clear();

        if (null !== $handler) {
            $this->push($handler);
        }

        $error = null;

        try {
            $result = $callable();
        } catch (Exception $error) {
            // re-thrown after handlers are restored
        }

        $this->restore($handlers);

        if (null !== $error) {
            throw $error;
        }

        return $result;
    }