Skip to content

Commit

Permalink
Improve error message when get_pages_url fails
Browse files Browse the repository at this point in the history
  • Loading branch information
object-Object committed Apr 9, 2024
1 parent 2c412c0 commit 4048bf2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
### Changed

* Print stdout and stderr when shell commands fail (fixes [#63](https://github.com/hexdoc-dev/hexdoc/issues/63)).
* Improve the error message when GitHub Pages is not enabled.

## `1!0.1.0a12`

Expand Down
7 changes: 6 additions & 1 deletion src/hexdoc/cli/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pathlib import Path
from typing import Literal, TypedDict, TypeVar, Unpack

from github import Auth, Github
from github import Auth, Github, UnknownObjectException
from github.Repository import Repository
from pydantic import TypeAdapter
from typer import Typer
Expand Down Expand Up @@ -149,6 +149,11 @@ def get_pages_url(repo: Repository) -> str:
_, data = repo._requester.requestJsonAndCheck("GET", endpoint)
except Exception as e:
e.add_note(f" Endpoint: {endpoint}")
if isinstance(e, UnknownObjectException):
e.add_note(
"Note: check if GitHub Pages is enabled in this repo"
+ " (https://github.com/hexdoc-dev/hexdoc-hexcasting-template/blob/d6f918f6f115/README.md#setting-up-pages)"
)
raise
return str(data["html_url"])

Expand Down

0 comments on commit 4048bf2

Please sign in to comment.