Skip to content

Commit 0e27918

Browse files
committed
fix: better messaging when can't find an object
1 parent af7191a commit 0e27918

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

quartodoc/builder/blueprint.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,15 @@ def _append_member_path(path: str, new: str):
5454

5555
return f"{path}:{new}"
5656

57-
def get_object_fixed(self, *args, **kwargs):
57+
def get_object_fixed(self, path, **kwargs):
5858
try:
59-
return self.get_object(*args, **kwargs)
59+
return self.get_object(path, **kwargs)
6060
except KeyError as e:
61-
raise WorkaroundKeyError(e.args[0])
61+
key_name = e.args[0]
62+
raise WorkaroundKeyError(
63+
f"Cannot find an object named: {key_name}."
64+
f" Does an object with the path {path} exist?"
65+
)
6266

6367
@dispatch
6468
def visit(self, el):

quartodoc/tests/test_builder_blueprint.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from quartodoc import get_object
22
from quartodoc import layout as lo
3-
from quartodoc.builder.blueprint import BlueprintTransformer, blueprint
3+
from quartodoc.builder.blueprint import (
4+
BlueprintTransformer,
5+
blueprint,
6+
WorkaroundKeyError,
7+
)
48
import pytest
59

610
TEST_MOD = "quartodoc.tests.example"
@@ -90,3 +94,15 @@ def test_blueprint_auto_package(bp):
9094
assert isinstance(res, lo.DocFunction)
9195
assert res.name == "a_func"
9296
assert res.anchor == "quartodoc.tests.example.a_func"
97+
98+
99+
def test_blueprint_lookup_error_message(bp):
100+
auto = lo.Auto(name="quartodoc.bbb.ccc")
101+
102+
with pytest.raises(WorkaroundKeyError) as exc_info:
103+
bp.visit(auto)
104+
105+
assert (
106+
"Does an object with the path quartodoc.bbb.ccc exist?"
107+
in exc_info.value.args[0]
108+
)

0 commit comments

Comments
 (0)