A solution is to do the verifying yourself or with a script beforehand and pass the valid files via the --input argument to the Typst file (docs: System Functions – Typst Documentation)
I highly recommend to only use assets which are available to you in a Typst project either from yourself or from packages, instead of relying on a try-catch basis. Meaning, if you provide content through a script or similar, name it accordingly and work with the --input parameter provided by the Typst app.
Typst at the end of the day is a type-setting system.
Sorry only just seen your message. If I’d got a notification that I needed to do something, I must have missed it.
Two line document:
#import "@preview/flagada:1.0.1" : *
#flag("CQ")
Command line compile, Windows, Version typst 0.14.2 (b33de9de)
typst c flag-test.typ
error: dictionary does not contain key "CQ" and no default value was specified
┌─ @preview/flagada:1.0.1\flags.typ:8279:2
│
8279 │ flags.at(upper(iso3166))
│ ^^^^^^^^^^^^^^^^^^^^^^^^
help: error occurred in this call of function `flag`
┌─ \\?\(file name)
│
2 │ #flag("CQ")
│ ^^^^^^^^^^
I see nothing in the FLAGDA documentation about providing a default flag name.
The error is because the flag function is defined as
#let flag(iso3166, height:.65em,) = {
assert(iso3166.len()==2 and type(iso3166)==str,message: "iso3166 code should be a string of 2 letters")
let flags = (
AD: flag-ad(height:height),
AE: flag-ae(height:height),
// ...
// 200 lines ommitted
// ...
ZW: flag-zw(height:height),
)
flags.at(upper(iso3166))
}
So it basically defines a dictionary called flags and tries to fetch the value at the key given by the user. The error is the same one you would get when attempting to access a non-existent key in any dictionary (see docs):