From fdcb2b43a9e921eb4407b0c747851fccb1fb3285 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Fri, 20 Nov 2026 01:50:50 +0000 Subject: [PATCH] Keep attributes so stores the error The split-tag scanner skipped the attributes on , so never stored the error text and every caught error read as "". Keep them in Tag::splitKeywords, and have use the catch tag's name and scope when the try tag itself has no name. Tested live on barant.com: and both store the error, including scope="session" and single-quoted attributes; the catch block still runs; no error leaves the name unset; nested tries catch body errors at the right level. Co-Authored-By: Claude Opus 5.5 --- Tag.cpp | 13 ++++++++++--- Tag.h | 6 ++++++ __trytag.cpp | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Tag.cpp b/Tag.cpp index 53ed10e..264db9a 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -222,13 +222,20 @@ namespace jet { in.skipWhitespace(); if(in.ifNext(">")) break; - else if(in.getTokenExclude("=").getLength() != 0) { + else if(coreutils::ZString attrName = in.getTokenExclude("="); attrName.getLength() != 0) { bool dq = in.ifNext("=\""); bool sq = !dq && in.ifNext("='"); if(dq || sq) { + // Keep the attribute (e.g. ) - it used + // to be skipped and dropped, so never + // stored the error and every caught error read as "". + char *valueStart = in.getCursor(); while(1) { - if(in.ifNext(dq ? "\"" : "'")) - break; + char *valueEnd = in.getCursor(); + if(in.ifNext(dq ? "\"" : "'")) { + splitKeywords[coreutils::MString(attrName)] = coreutils::MString(coreutils::ZString(valueStart, valueEnd - valueStart)); + break; + } in.nextChar(); } } else { diff --git a/Tag.h b/Tag.h index eb4c0a4..2e70666 100644 --- a/Tag.h +++ b/Tag.h @@ -139,6 +139,12 @@ namespace jet { void scanContainerNamed(coreutils::ZString &in, const char *tagName); coreutils::MString processModifier(coreutils::MString &value, coreutils::MString &modifier); + + public: + // The split tag's own attributes (raw, unresolved) - e.g. 's + // , so __trytag can bind the error to that name. + // Last member on purpose: adding it changes no other member's offset. + std::map splitKeywords; }; } diff --git a/__trytag.cpp b/__trytag.cpp index 12ef1a5..f22c48d 100644 --- a/__trytag.cpp +++ b/__trytag.cpp @@ -30,9 +30,13 @@ namespace jet { // without this a caught mid-render failure would leave partial // try-block output mixed in ahead of the catch block's own. out = ""; + // or (the usual form). if(keywordDefined("name")) storeVariable(resolveKeyword("name"), errorText, keywordDefined("scope") ? resolveKeyword("scope") : "global"); + else if(splitKeywords.count("name")) + storeVariable(splitKeywords["name"], errorText, + splitKeywords.count("scope") ? coreutils::ZString(splitKeywords["scope"]) : coreutils::ZString("global")); if(hasContainer2) processContainer(container2); }