tonhowtf/omniget · error
escreva o texto da marca d'água
Error message
escreva o texto da marca d'água
What it means
watermark_one stamps text onto every page; if opts.text is blank (after trim) and mode is not "bates", there is nothing to draw, so it returns 'escreva o texto da marca d'água'. Bates numbering supplies its own digits, so it is exempt.
Solutions
- Provide non-empty opts.text for normal watermark modes
- Use mode="bates" if the intent is sequential Bates numbering instead of a text stamp
- Validate text.trim().is_empty() in the caller before invoking
Example fix
// before
watermark_one(&WatermarkOptions { text: "".into(), ..Default::default() }, input)?;
// after
let text = "CONFIDENCIAL";
assert!(!text.trim().is_empty(), "texto da marca d'água obrigatório");
watermark_one(&WatermarkOptions { text: text.into(), ..Default::default() }, input)?; Defensive patterns
Strategy: validation
Validate before calling
if opts.mode != "bates" && opts.text.trim().is_empty() {
anyhow::bail!("informe o texto da marca d'água ou use o modo bates");
} Type guard
fn watermark_text_ok(opts: &WatermarkOptions) -> bool {
opts.mode == "bates" || !opts.text.trim().is_empty()
} Try / catch
match watermark_one(&opts, input) {
Ok(item) => item,
Err(e) if e.to_string().contains("marca d'água") => {
eprintln!("texto da marca d'água é obrigatório");
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Mark the watermark text field as required in UIs unless Bates mode is selected
- Trim and validate text before passing options
- Default to mode="bates" when no text is supplied
When it happens
Trigger: Calling watermark with mode != "bates" and WatermarkOptions::text empty or whitespace-only.
Common situations: User leaves the watermark text field blank in a UI; caller passes Default::default() options; text lost in config deserialization; using "bates" intent but forgetting to set mode="bates".
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- defina pelo menos uma senha
- escolha o PDF
- documento sem páginas
- escolha a pasta de destino
- escolha a pasta de destino
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/dafa4dd3c319665f.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf_write.rs:351
.ok()
.and_then(|(_, ids)| ids.first().copied());
match inherited {
Some(id) => Some(id),
None => {
let id = doc.add_object(Object::Dictionary(dictionary! {}));
if let Ok(page) = doc.get_dictionary_mut(page_id) {
page.set("Resources", Object::Reference(id));
}
Some(id)
}
}
}
}
}
fn watermark_one(opts: &WatermarkOptions, input: &str) -> anyhow::Result<WriteItem> {
if opts.text.trim().is_empty() && opts.mode != "bates" {
return Err(anyhow!("escreva o texto da marca d'água"));
}
let mut doc = load(input, "")?;
let pages = doc.get_pages();
let font_id = doc.add_object(dictionary! {
"Type" => "Font",
"Subtype" => "Type1",
"BaseFont" => "Helvetica",
});
let alpha = (opts.opacity.min(100) as f32) / 100.0;
let gs_id = doc.add_object(dictionary! {
"Type" => "ExtGState",
"ca" => alpha,
"CA" => alpha,
});
let gray = (opts.gray.min(100) as f32) / 100.0;
let ids: Vec<(u32, lopdf::ObjectId)> = pages.iter().map(|(n, id)| (*n, *id)).collect();
for (index, (_, page_id)) in ids.iter().enumerate() {View on GitHub (pinned to 8600b91f42)