Stream: beginners

Topic: Stack trace on error


view this post on Zulip Scally (Nov 18 2024 at 00:54):

Is there any way to get a stack trace from errors?
I have some PathDoesNotExist error reaching the top level of my basic-cli main function but it's quite annoying to try figuring out what line caused it originally.

view this post on Zulip Luke Boswell (Nov 18 2024 at 01:12):

I find wrapping my errors with another tag is a nice way to add additional context. Then when it bubbles all the way to the top (if I don't handle it) then I get a more helpful error message.

Here is an example that uses mapErr with a tag.

view this post on Zulip Luke Boswell (Nov 18 2024 at 01:13):

I also find adding type annotations can help on functions, or using the hover in my editor to see the inferred type at a given point, can help track down where it's coming from.

view this post on Zulip Brendan Hansknecht (Nov 18 2024 at 02:00):

Theoretically crashing with the error can give a backtrack, but I don't think it is reliable


Last updated: Jul 05 2025 at 12:14 UTC