faet(Exception): add ForkProjectError

This commit is contained in:
江畅
2020-08-25 18:18:52 +08:00
parent b146992549
commit a273cb0fe9
2 changed files with 14 additions and 2 deletions
+12
View File
@@ -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.
"""
+2 -2
View File
@@ -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'])