Skip to content
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

Track type name on error before losing that info #213

Merged
merged 2 commits into from
Aug 12, 2020

Conversation

jbr
Copy link
Member

@jbr jbr commented Aug 5, 2020

If this turns out to have meaningful performance implications, we could feature flag this or just do it conditionally when debug_assertions are on.

This combines well with #212 to allow for this sort of development-mode error handler in tide:
image

@jbr
Copy link
Member Author

jbr commented Aug 5, 2020

(I'm thinking the dev-mode-error-handler is something I probably could/should extract, once it's polished up. Not sure if it should live in tide or as an external crate, since it's somewhat opinionated, but assumedly opt-in)

src/error.rs Outdated Show resolved Hide resolved
@jbr jbr mentioned this pull request Aug 6, 2020
Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::any::type_name returns an &'static str; this means we can inline it in the struct without performing any new allocations. This doesn't mean that tracking the type name is free; but it should at least save some of the cost.

If we can change that this PR should be good to merge!

src/error.rs Outdated Show resolved Hide resolved
src/error.rs Outdated Show resolved Hide resolved
@goto-bus-stop goto-bus-stop changed the base branch from master to main August 9, 2020 12:58
jbr and others added 2 commits August 10, 2020 17:36
keep the type_name a &'static str

Co-authored-by: Yoshua Wuyts <yoshuawuyts+github@gmail.com>
@jbr jbr dismissed yoshuawuyts’s stale review August 11, 2020 00:38

Made the suggested changes, Error holds a &'static str now

@Fishrock123
Copy link
Member

This looks merge-able?

@jbr jbr merged commit 67674bb into http-rs:main Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants