Skip to content

Catch panics inside context #211

Description

@Andrew15-5

Description

I have a template which has a context assertion. If it panics (i.e., fails), tt doesn't catch it:

#import "...": template

#let document() = [
  #show: template
  ...
]

#assert-panic(document) // Doesn't panic.
// #context assert.eq(catch(document), none) // Doesn't panic.
#document() // Panics.

Alternative Solutions

Hoist context outside of assert-panic/catch, but then users must use this:

#show: doc => context {
  show: template.with(
    ...
  )
  doc
}

Which is not acceptable.

Additional Context

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-test-libArea: typst test libraryA-testsArea: anything actually test relatedC-upstreamCategory: this is related to or blocked by an upstream issue or PRP-mediumPriority: mediumS-needs-investigationStatus: further information is required

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions