add alternate implementations of error_chain that do not require types section #8

Merged
merged 2 commits into from Jul 21, 2016

Conversation

Projects
None yet
2 participants
@natemara

I added two alternate implementations of the error_chain macro. One allows for an empty types block, the other leaves the types block out entirely. This should fix #5. I also ran rustfmt on lib.rs and quick_error.rs.

@brson

This comment has been minimized.

Show comment
Hide comment
@brson

brson Jul 21, 2016

Contributor

@natemara Thank you so much! The comments look like they've been mis-formatted though (they're all unindented now). Can you take a look?

Contributor

brson commented Jul 21, 2016

@natemara Thank you so much! The comments look like they've been mis-formatted though (they're all unindented now). Can you take a look?

@natemara

This comment has been minimized.

Show comment
Hide comment
@natemara

natemara Jul 21, 2016

This looks like an issue with rustfmt not handling long lines correctly in macro_rules! blocks. For the time being, I'll shorten the offending line by breaking it in two. I have opened an issue with rustfmt

rust-lang-nursery/rustfmt#1105

This looks like an issue with rustfmt not handling long lines correctly in macro_rules! blocks. For the time being, I'll shorten the offending line by breaking it in two. I have opened an issue with rustfmt

rust-lang-nursery/rustfmt#1105

@@ -331,7 +331,9 @@ macro_rules! quick_error {
(FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt
{ display($self_:tt) -> ($( $exprs:tt )*) $( $tail:tt )*}
) => {
- |quick_error!(IDENT $self_): &$name, f: &mut ::std::fmt::Formatter| { write!(f, $( $exprs )*) }

This comment has been minimized.

@natemara

natemara Jul 21, 2016

This is the line that was causing problems. Rustfmt will complain if you have a line longer than 100 characters.

@natemara

natemara Jul 21, 2016

This is the line that was causing problems. Rustfmt will complain if you have a line longer than 100 characters.

@@ -46,6 +46,8 @@ define an `errors` module and inside it call `error_chain!`:
error_chain! {
// The type defined for this error. These are the conventional
// and recommended names, but they can be arbitrarily chosen.
+ // It is also possible to leave this block out entirely, or
+ // leave it empty, and these names will be used automatically.

This comment has been minimized.

@brson

brson Jul 21, 2016

Contributor

This is still indented wrong.

@brson

brson Jul 21, 2016

Contributor

This is still indented wrong.

@brson

This comment has been minimized.

Show comment
Hide comment
@brson

brson Jul 21, 2016

Contributor

Just one last nit.

Contributor

brson commented Jul 21, 2016

Just one last nit.

@brson brson merged commit 801be38 into rust-lang-nursery:master Jul 21, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@brson

This comment has been minimized.

Show comment
Hide comment
@brson

brson Jul 21, 2016

Contributor

I'll fix the remaining indent in a followup. Thanks @natemara !

Contributor

brson commented Jul 21, 2016

I'll fix the remaining indent in a followup. Thanks @natemara !

@natemara

This comment has been minimized.

Show comment
Hide comment
@natemara

natemara Jul 21, 2016

Glad to help!

Glad to help!

@brson

This comment has been minimized.

Show comment
Hide comment
@brson

brson Jul 21, 2016

Contributor

@natemara I've published this as error-chain 0.2.2.

Contributor

brson commented Jul 21, 2016

@natemara I've published this as error-chain 0.2.2.

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