Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 57abf4dc authored by Dorian Turba's avatar Dorian Turba
Browse files

better errors

parent c551cf94
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,10 @@ def _project(
if e.response_code == http.HTTPStatus.UNAUTHORIZED:
raise release_by_changelog.exc.UnauthorizedError from e
raise e
except gitlab.GitlabGetError as e:
if e.response_code == http.HTTPStatus.NOT_FOUND:
raise release_by_changelog.exc.ProjectNotFoundError from e
raise e
project_name = f"{project_.namespace.get('full_path')}/{project_.name}"
console.print(
f"[bold green]Project found:[/bold green] [bold cyan]{project_name}[bold cyan]"
......
......@@ -76,6 +76,13 @@ def release(
except release_by_changelog.exc.UnauthorizedError:
err_console.print("Error: Unauthorized", style="bold red")
raise typer.Exit(code=1)
except release_by_changelog.exc.ProjectNotFoundError:
err_console.print(
"Error: Project not found.",
"Possible remediation: Provide the full path to the project.",
style="bold red",
)
raise typer.Exit(code=1)
console.print(f"Processing [bold cyan]{changelog_path}[/bold cyan]")
changelog_entry = _last_changelog(changelog_path)
......@@ -84,7 +91,29 @@ def release(
f"[bold cyan]{changelog_entry.version}[/bold cyan]"
)
project_, project_name = _project(token, host, project, console)
try:
project_, project_name = _project(token, host, project, console)
except release_by_changelog.exc.UnauthorizedError:
err_console.print("Error: Unauthorized", style="bold red")
raise typer.Exit(code=1)
except release_by_changelog.exc.ProjectNotFoundError:
err_console.print(
"Error: Project not found.",
"Possible remediation:",
"\t- Provide the project ID. To find the project ID, go to the project page"
", click on the three vertical dot button on the top right corner and press"
" the 'Copy project ID: XXXX' button.",
"\t- Provide the full path to the project. To find it, go to the project "
"page, check at the url and copy the path after the host. "
"If the following link doesn't point to your project, you got the "
f"namespace wrong: 'https://{host}/{project}'",
"\t- Check if the host is correct. If you are using a self-hosted GitLab, "
"you need to provide the correct host. Current host: "
f"'https://{host}', is that where your project is hosted?",
style="bold red",
sep="\n",
)
raise typer.Exit(code=1)
if interact:
typer.confirm("Do you confirm release?", default=True, abort=True)
......
......@@ -4,3 +4,7 @@ class UnauthorizedError(Exception):
class ReleaseAlreadyExistError(Exception):
pass
class ProjectNotFoundError(Exception):
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment