From cdafe55150a7f66a53c37400659f2c1f1c511a5f Mon Sep 17 00:00:00 2001 From: Denis Silakov Date: Sun, 29 Jan 2017 12:15:31 +0300 Subject: [PATCH] Correclty report an error when repo name for a fork/alias is already taken --- abf/api/exceptions.py | 6 +++--- abf/api/jsn.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/abf/api/exceptions.py b/abf/api/exceptions.py index 60dcf53..97a211f 100644 --- a/abf/api/exceptions.py +++ b/abf/api/exceptions.py @@ -1,13 +1,10 @@ - class AbfApiException(Exception): pass - class PageNotFoundError(AbfApiException): pass - class AuthError(AbfApiException): pass @@ -25,3 +22,6 @@ class ServerWorksError(AbfApiException): class BadRequestError(AbfApiException): pass + +class NameTakenError(AbfApiException): + pass diff --git a/abf/api/jsn.py b/abf/api/jsn.py index d2adcc3..e42b1c5 100644 --- a/abf/api/jsn.py +++ b/abf/api/jsn.py @@ -73,6 +73,7 @@ class AbfJson(object): "Invalid email or password.": AuthError, "403 Forbidden | Rate Limit Exceeded": RateLimitError, "Page not found": PageNotFoundError, + "Project has not been forked. Name has already been taken": NameTakenError, "Error 404. Resource not found!": PageNotFoundError, "Something went wrong. We've been notified about this issue and we'll take a look at it shortly.": InternalServerError, "We update the site, it will take some time. We are really trying to do it fast. We apologize for any inconvenience..": ServerWorksError, @@ -102,6 +103,9 @@ class AbfJson(object): # when this project is already assigned to some repo of the same platform if 'message' in res['repository'] and 'error' in res['repository']['message']: m = res['repository']['message'] + elif 'project' in res: + if 'message' in res['project'] and ('error' in res['project']['message'] or 'has not been' in res['project']['message']): + m = res['project']['message'] if 'error' in res: m = res['error'] if 'Error' in res: