Skip to content

Commit

Permalink
panic on key not found
Browse files Browse the repository at this point in the history
  • Loading branch information
slashformotion committed Apr 27, 2024
1 parent 3fd69d7 commit 5b84a66
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions glossarium.typ
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ SOFTWARE.*/
// global state containing the glossary entry and their location
#let __glossary_entries = state("__glossary_entries", (:))

#let __glossarium_error_prefix = "glossarium error : "

#let __query_labels_with_key(loc, key, before: false) = {
if before {
query(
Expand All @@ -24,6 +26,11 @@ SOFTWARE.*/
}
}

// key not found error
#let __not-found-panic-error-msg(key) = {
__glossarium_error_prefix+"key '"+key+"' not found"
}

// Reference a term
#let gls(key, suffix: none, long: none, display: none) = {
context {
Expand All @@ -45,7 +52,7 @@ SOFTWARE.*/

[#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)]
} else {
text(fill: red, "Glossary entry not found: " + key)
panic(__not-found-panic-error-msg(key))
}
}
}
Expand Down Expand Up @@ -89,7 +96,7 @@ SOFTWARE.*/

[#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)]
} else {
text(fill: red, "Glossary entry not found: " + key)
panic(__not-found-panic-error-msg(key))
}
}
}
Expand Down

0 comments on commit 5b84a66

Please sign in to comment.