Skip to content

Commit cf2d10a

Browse files
committed
fix: report handlebars errors from Builder
1 parent a9b6774 commit cf2d10a

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

include/mrdocs/Support/Error.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2809,7 +2809,7 @@ struct fmt::formatter<clang::mrdocs::Error>
28092809
clang::mrdocs::Error const& err,
28102810
fmt::format_context& ctx) const
28112811
{
2812-
return fmt::formatter<std::string_view>::format(err.reason(), ctx);
2812+
return fmt::formatter<std::string_view>::format(err.message(), ctx);
28132813
}
28142814
};
28152815

src/lib/-adoc/MultiPageVisitor.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ operator()(T const& I)
5050
{
5151
ex_.async([this, &I](Builder& builder)
5252
{
53-
writePage(builder(I).value(),
54-
builder.domCorpus.getXref(I));
53+
if(const auto r = builder(I))
54+
writePage(*r, builder.domCorpus.getXref(I));
55+
else
56+
r.error().Throw();
5557
if constexpr(
5658
T::isNamespace() ||
5759
T::isRecord() ||
@@ -69,8 +71,10 @@ operator()(OverloadSet const& OS)
6971
{
7072
ex_.async([this, OS](Builder& builder)
7173
{
72-
writePage(builder(OS).value(),
73-
builder.domCorpus.getXref(OS));
74+
if(const auto r = builder(OS))
75+
writePage(*r, builder.domCorpus.getXref(OS));
76+
else
77+
r.error().Throw();
7478
corpus_.traverse(OS, *this);
7579
});
7680
}

src/lib/-adoc/SinglePageVisitor.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ void
2020
SinglePageVisitor::
2121
operator()(T const& I)
2222
{
23-
ex_.async(
24-
[this, &I, page = numPages_++](Builder& builder)
25-
{
26-
writePage(builder(I).value(), page);
27-
});
23+
ex_.async([this, &I, page = numPages_++](Builder& builder)
24+
{
25+
if(auto r = builder(I))
26+
writePage(*r, page);
27+
else
28+
r.error().Throw();
29+
});
2830
if constexpr(
2931
T::isNamespace() ||
3032
T::isRecord() ||
@@ -41,7 +43,10 @@ operator()(OverloadSet const& OS)
4143
{
4244
ex_.async([this, OS, page = numPages_++](Builder& builder)
4345
{
44-
writePage(builder(OS).value(), page);
46+
if(auto r = builder(OS))
47+
writePage(*r, page);
48+
else
49+
r.error().Throw();
4550
corpus_.traverse(OS, *this);
4651
});
4752
}

src/lib/Support/Error.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,18 @@ Error::
4242
formatWhere(
4343
source_location const& loc)
4444
{
45+
return fmt::format("{}:{}",
46+
::SourceFileNames::getFileName(
47+
loc.file_name()),
48+
loc.line());
49+
#if 0
4550
return fmt::format(
4651
"{}@{}({})",
4752
loc.function_name(),
4853
::SourceFileNames::getFileName(
4954
loc.file_name()),
5055
loc.line());
56+
#endif
5157
}
5258

5359
std::string
@@ -58,8 +64,9 @@ formatMessage(
5864
{
5965
std::string result;
6066
result = reason;
61-
result.append(": ");
67+
result.append(" (");
6268
result.append(where);
69+
result.append(")");
6370
return result;
6471
}
6572

src/tool/ToolMain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int mrdocs_main(int argc, char const** argv)
7575

7676
// Generate
7777
if(auto err = DoGenerateAction())
78-
report::error("Generating reference failed: {}", err);
78+
report::error("Generating reference failed: {}", err.message());
7979

8080
if( report::results.errorCount > 0 ||
8181
report::results.fatalCount > 0)

0 commit comments

Comments
 (0)