public function addError($error, $key = null)
    {
        if (is_string($error)) {
            $error = new Exception($error);
        } elseif ($error instanceof Exception) {
            // Nothing to do
        } else {
            throw new Exception('only string errors or instances of Exception can be added');
        }

        if ($key) {
            $this->errors[$key] = $error;
        } else {
            $this->errors[] = $error;
        }

        return false;
    }