mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 10:08:00 -06:00
M6: a document script's error is told apart by where it came from, not its wording (#3940)
Review follow-up on #3985: JsOutput deduplicated document-script errors by their text (document script N: ...), so a field script that threw the same words was dropped by append, and a document script's error was dropped by absorb when a field script had already reported that text. JsOutput now records which errors came from document scripts (doc_errors) and deduplicates only those; pdfcraft_js::is_doc_error, which guessed from the wording, is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a7afaacbb9
commit
994ce63099
+1
-13
@@ -1274,21 +1274,9 @@ impl HostHooks for CheckedCodeFromStrings {
|
||||
}
|
||||
}
|
||||
|
||||
/// The prefix of a document script's error ([`doc_error`]).
|
||||
const DOC_ERROR_PREFIX: &str = "document script ";
|
||||
|
||||
/// How [`Outcome::doc_errors`] names a failing document script: by its 1-based place.
|
||||
fn doc_error(index: usize, error: &dyn std::fmt::Display) -> String {
|
||||
format!("{DOC_ERROR_PREFIX}{}: {error}", index.saturating_add(1))
|
||||
}
|
||||
|
||||
/// Whether `error` is one of [`Outcome::doc_errors`]: a document script's failure, which repeats
|
||||
/// each time the document scripts run again, unlike a field script's own error.
|
||||
pub fn is_doc_error(error: &str) -> bool {
|
||||
error
|
||||
.strip_prefix(DOC_ERROR_PREFIX)
|
||||
.and_then(|rest| rest.split_once(": "))
|
||||
.is_some_and(|(n, _)| !n.is_empty() && n.bytes().all(|b| b.is_ascii_digit()))
|
||||
format!("document script {}: {error}", index.saturating_add(1))
|
||||
}
|
||||
|
||||
/// `doc_scripts` are the document scripts to run with their places among all of them;
|
||||
|
||||
Reference in New Issue
Block a user