8000 Proper usage of exceptions under Python3 · Issue #939 · python-gitlab/python-gitlab · GitHub
[go: up one dir, main page]

Skip to content 8000
Proper usage of exceptions under Python3 #939
Closed
@ericfrederich

Description

@ericfrederich

Description of the problem, including code/CLI snippet

Python3 has support to raise from to distinguish between the following circumstances:

  • an exception while handling another exception
  • an exception which is the direct cause of another

For instance when a project doesn't exist as in the code below, you'll see two exceptions:

  • gitlab.exceptions.GitlabHttpError
  • gitlab.exceptions.GitlabGetError
import os
import gitlab

gl = gitlab.Gitlab(
    url=os.environ['GITLAB_URL'],
    private_token=os.environ['GITLAB_TOKEN'],
    api_version="4",
)
gl.auth()

gl.projects.get('non-existent-project')

On Python3 between the two exceptions you'll see the statement: During handling of the above exception, another exception occurred:

This is clearly not the case.

Expected Behavior

You see in the console between the two exceptions:

The above exception was the direct cause of the following exception:

Actual Behavior

You see in the console between the two exceptions:

During handling of the above exception, another exception occurred:

Specifications

  • python-gitlab version: 1.13.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 12.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0