From a273cb0fe99316ea1a1b5625029f89015610d4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E7=95=85?= <631866165@qq.com> Date: Tue, 25 Aug 2020 18:18:52 +0800 Subject: [PATCH] faet(Exception): add ForkProjectError --- error.py | 12 ++++++++++++ project.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/error.py b/error.py index 8559d91..f8476c0 100644 --- a/error.py +++ b/error.py @@ -65,6 +65,18 @@ class PullRequestError(Exception): def __str__(self): return self.reason + +class ForkProjectError(Exception): + """ pull request to Gitee did not succeed. + """ + + def __init__(self, reason): + super(ForkProjectError, self).__init__() + self.reason = reason + + def __str__(self): + return self.reason + class GitError(Exception): """Unspecified internal error from git. """ diff --git a/project.py b/project.py index 8d9bc84..e4307f7 100644 --- a/project.py +++ b/project.py @@ -36,7 +36,7 @@ from color import Coloring from git_command import GitCommand, git_require from git_config import GitConfig, IsId, GetSchemeFromUrl, GetUrlCookieFile, \ ID_RE -from error import GitError, HookError, UploadError, DownloadError, PullRequestError +from error import GitError, HookError, UploadError, DownloadError, PullRequestError, ForkProjectError from error import ManifestInvalidRevisionError, ManifestInvalidPathError from error import NoManifestException import platform_utils @@ -1477,7 +1477,7 @@ class Project(object): if not token: token = GitConfig.ForUser().GetString('repo.token') if not token: - raise PullRequestError('repo.token is None, Please set it before pushing, you need `repo config -h`') + raise ForkProjectError('repo.token is None, Please set it before pushing, you need `repo config -h`') gitee_url = 'https://gitee.com/api/v5/repos' namespace = self._GiteeNamespace(type='upload') post_url = '/'.join([gitee_url, namespace, self.name, 'forks'])