How to use the tsrc.gitlab.GitLabAPIError function in tsrc

To help you get started, we’ve selected a few tsrc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TankerHQ / tsrc / tsrc / gitlab.py View on Github external
def _handle_stream_errors(response):
    if response.status_code >= 400:
        raise GitLabAPIError(response.url, "Incorrect status code:", response.status_code)
github TankerHQ / tsrc / tsrc / gitlab.py View on Github external
def get_project_id(self, project_name):
        encoded_project_name = urllib.parse.quote(project_name, safe=list())
        url = "/projects/%s" % encoded_project_name
        try:
            res = self.make_request("GET", url)
            return res["id"]
        except GitLabAPIError as e:
            if e.status_code == 404:
                raise GitLabAPIError(url, 404, "Project not found: %s" % project_name) from None
            else:
                raise
github TankerHQ / tsrc / tsrc / gitlab.py View on Github external
def _handle_json_errors(response):
    # Make sure we always have a dict containing some
    # kind of error:
    json_details = dict()
    try:
        json_details = response.json()
    except ValueError:
        json_details["error"] = ("Expecting json result, got %s" % response.text)

    status_code = response.status_code
    url = response.url
    if 400 <= status_code < 500:
        for key in ["error", "message"]:
            if key in json_details:
                raise GitLabAPIError(url, status_code, json_details[key])
        raise GitLabAPIError(url, status_code, json_details)
    if status_code >= 500:
        raise GitLabAPIError(url, status_code, response.text)
github TankerHQ / tsrc / tsrc / gitlab.py View on Github external
# kind of error:
    json_details = dict()
    try:
        json_details = response.json()
    except ValueError:
        json_details["error"] = ("Expecting json result, got %s" % response.text)

    status_code = response.status_code
    url = response.url
    if 400 <= status_code < 500:
        for key in ["error", "message"]:
            if key in json_details:
                raise GitLabAPIError(url, status_code, json_details[key])
        raise GitLabAPIError(url, status_code, json_details)
    if status_code >= 500:
        raise GitLabAPIError(url, status_code, response.text)
github TankerHQ / tsrc / tsrc / gitlab.py View on Github external
def _handle_json_errors(response):
    # Make sure we always have a dict containing some
    # kind of error:
    json_details = dict()
    try:
        json_details = response.json()
    except ValueError:
        json_details["error"] = ("Expecting json result, got %s" % response.text)

    status_code = response.status_code
    url = response.url
    if 400 <= status_code < 500:
        for key in ["error", "message"]:
            if key in json_details:
                raise GitLabAPIError(url, status_code, json_details[key])
        raise GitLabAPIError(url, status_code, json_details)
    if status_code >= 500:
        raise GitLabAPIError(url, status_code, response.text)
github TankerHQ / tsrc / tsrc / gitlab.py View on Github external
def get_project_id(self, project_name):
        encoded_project_name = urllib.parse.quote(project_name, safe=list())
        url = "/projects/%s" % encoded_project_name
        try:
            res = self.make_request("GET", url)
            return res["id"]
        except GitLabAPIError as e:
            if e.status_code == 404:
                raise GitLabAPIError(url, 404, "Project not found: %s" % project_name) from None
            else:
                raise