Skip to content

Expose the ZoneSpecification print handler #1864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
feinstein opened this issue Nov 15, 2024 · 2 comments
Closed

Expose the ZoneSpecification print handler #1864

feinstein opened this issue Nov 15, 2024 · 2 comments

Comments

@feinstein
Copy link

I currently have my app wrapped by a runZonedGuarded and wanted to wrap it instead with a Chain.capture to get full stack traces, but I can't because my app needs the ZoneSpecification print handler, which is not currently exposed by this package.

@lrhn
Copy link
Member

lrhn commented Apr 30, 2025

As mentioned in the linked pull request, you can nest zones, so you don't need every zone-introducing function to allow a zone specification on top.

Just do:

Chain.capture(() => runZonedGuarded(zoneSpecification: ZoneSpecification(print: _handlePrint), () {
   // actual code
}))

or

runZonedGuarded(zoneSpecification: ZoneSpecification(print: _handlePrint), () => Chain.capture(() { 
   // actual code
}))

Either works, I doubt they'll step on each other's definitions.

The result is a zone which has all the handlers of their parent zones.

@lrhn lrhn closed this as completed Apr 30, 2025
@feinstein
Copy link
Author

@lrhn thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants