Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Conversation

@thomcc
Copy link
Contributor

@thomcc thomcc commented Jul 23, 2018

This adds a lot of boilerplate which could be simplified by macros.

I was planning on cleaning this up before pushing it but here it is!

Caveat: I haven't tested this in versions of rust other than whatever i happen to be using by default right now! I did try to make the changes compatible with 1.25.0 (e.g. &/ref noise in matches) but that was just to minimize future work and I might not have been thorough here

This adds a lot of boilerplate which could be simplified by macros.

I was planning on cleaning this up before pushing it but here it is!
Copy link
Contributor

@grigoryk grigoryk left a comment

Choose a reason for hiding this comment

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

Pardon my ignorance, but could you explain how the added split of Error/ErrorKind actually helps preserve backtraces? It's not clear to me what this achieves beyond adding another layer into the error cake - but I'm sure I'm missing something.

}

#[derive(Debug)]
pub struct AlgebrizerError(Box<Context<AlgebrizerErrorKind>>);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear to me why you're boxing the Context. Can you explain why?

@grigoryk
Copy link
Contributor

Okay, after reading a tad more and talking to Thom, I understand why this works. As should have been obvious, just deriving a Fail trait won't provide our error enums with a place to store backtrace.

And so, something like this is basically what we'd want - a struct to host bunch of contextual information, a lightweight enum for actual error types, and some glue to tie it all together.

It's not clear to me why we need to Box stuff. You mentioned reducing memcpy traffic in case of large ErrorKinds, but in our case they're mostly just simple enums with an i64 or sometimes a String in them. Could you explain your reasoning here?

Otherwise, maybe a clean-up with some macros? That would either mean duplicating the macros in a bunch of places, or having them live in core and growing an extra dependency in other crates (except edn...), or adding a new lightweight macros crate that we can re-use. I think the latter is the winner out of the three options.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants