From 4048bf2c738f5dc61230200ec40b97d7ee303702 Mon Sep 17 00:00:00 2001 From: object-Object Date: Tue, 9 Apr 2024 13:42:04 -0400 Subject: [PATCH] Improve error message when get_pages_url fails --- CHANGELOG.md | 1 + src/hexdoc/cli/ci.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f5c138..bf4372d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/hexdoc/cli/ci.py b/src/hexdoc/cli/ci.py index 4527c2c3..ce95779b 100644 --- a/src/hexdoc/cli/ci.py +++ b/src/hexdoc/cli/ci.py @@ -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 @@ -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"])