From cbddbd2a8b9fe7cfe9039e1d1ba8d4f88bdd6e07 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 26 Aug 2019 11:30:04 +0200 Subject: [PATCH] Missing types raise an exception, fix #107 --- docs/Type/Perl6/Documentable/Primary.pod6 | 13 +++++++++++++ lib/Perl6/Documentable/DocPage/Primary.pm6 | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/Type/Perl6/Documentable/Primary.pod6 b/docs/Type/Perl6/Documentable/Primary.pod6 index 5297ddc..ae92ccc 100644 --- a/docs/Type/Perl6/Documentable/Primary.pod6 +++ b/docs/Type/Perl6/Documentable/Primary.pod6 @@ -277,4 +277,17 @@ must follow the format: =end code +=end pod + +=begin pod :kind("type") :subkind("class") :category("exception") + +=TITLE class X::Documentable::TypeNotFound + +=SUBTITLE Missing type in type-graph file + + X::Documentable::TypeNotFound is Exception {} + +Attempt to create the typegraph representation of a missing type. To fix it, add that type +to the type-graph file you are using. + =end pod \ No newline at end of file diff --git a/lib/Perl6/Documentable/DocPage/Primary.pm6 b/lib/Perl6/Documentable/DocPage/Primary.pm6 index 514d4bd..2005487 100644 --- a/lib/Perl6/Documentable/DocPage/Primary.pm6 +++ b/lib/Perl6/Documentable/DocPage/Primary.pm6 @@ -5,6 +5,13 @@ use URI::Escape; use Pod::Utilities::Build; use Perl6::Documentable; +class X::Documentable::TypeNotFound is Exception { + has $.type; + method message() { + "$.type entry not found in type-graph.txt file." + } +} + class Perl6::Documentable::DocPage::Primary::Language does Perl6::Documentable::DocPage { @@ -125,7 +132,8 @@ class Perl6::Documentable::DocPage::Primary::Type #| Completes a type pod with inherited routines method compose-type($registry, $doc) { - {return;} unless $registry.tg.types{$doc.name}; + die X::Documentable::TypeNotFound.new(:type("$doc.name")) + unless $registry.tg.types{$doc.name}; $doc.pod.contents.append: self.typegraph-fragment($doc.name);