Argtype descriptions name a literal parameter's cost, a phase's error is the phase's report, the ^-code table's grave-accent and dieresis rows (from dev ee86ca467512)
This commit is contained in:
1 parent
f4dcdf3ffd
commit
35ca469e4d
7 files changed
+66
-6
No files matched your search
+27
-2
@@ -909,7 +909,9 @@ std::string Machine::run_phase_functions()
|
||||
// result text. The Eval is constructed per phase so a chained
|
||||
// phase sees its predecessor's result in K_result.
|
||||
Eval E(*this, Locator());
|
||||
if (!f.empty() && f[0] != ':') {
|
||||
const std::string spec = f;
|
||||
const bool python_phase = !f.empty() && f[0] != ':';
|
||||
if (python_phase) {
|
||||
// K reaches a phase only as a parameter: the state's
|
||||
// "class K" exists in the EVAL's globals (python_code()
|
||||
// defines it), but a phase function's body resolves names in
|
||||
@@ -929,7 +931,30 @@ std::string Machine::run_phase_functions()
|
||||
// Klammertext: take the raw result string. Re-reading it as
|
||||
// Klammertext (Eval::eval) would misparse target characters --
|
||||
// e.g. a "@" from a quoted ^@ in justified txt output.
|
||||
m_result = E.eval_command(katoms.begin(), katoms.end() - 2);
|
||||
try {
|
||||
m_result = E.eval_command(katoms.begin(), katoms.end() - 2);
|
||||
} catch (const Parsing_error& e) {
|
||||
// A Python phase's exception is the phase's report about the
|
||||
// document, not a parsing error at "phase, line 1": a phase
|
||||
// raises ValueError to say what is wrong (phases.
|
||||
// check_section_links), and that message is what the user
|
||||
// needs headlined, located nowhere -- the phase ran over the
|
||||
// whole target text, so no line is the place. Any other
|
||||
// exception type is a fault in the phase itself and keeps
|
||||
// its type name. The traceback the Parsing_error carried is
|
||||
// the trace, at -v 2. (TODO 77, 2026-10-13)
|
||||
if (!python_phase) throw;
|
||||
(void)K::log(2, e.m_desc);
|
||||
std::string what = last_python_exception_text();
|
||||
const std::string type = last_python_exception_type();
|
||||
if (what.empty()) throw;
|
||||
if (type != "ValueError") what = type + ": " + what;
|
||||
throw Target_error(
|
||||
what + "\n\n(Reported by the " + m_state.value("K_target")
|
||||
+ " target's phase " + spec
|
||||
+ "; -v 2 shows the Python traceback.)",
|
||||
Locator::none());
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_result;
|
||||
|
||||
Reference in new issue
Block a user