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

Clean up MockException (and deprecate IError along the way) #634

Merged
merged 3 commits into from
Jun 16, 2018

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Jun 16, 2018

MockException currently feels quite messy because it has many similar constructors that all do something slightly different. It's dificult to understand what kind of exception is built up at the throw sites. Also, some MockExceptions have an IError payload, while others don't. Either we should go IError all the way, or remove it.

This PR opts for removing the IError abstraction by introducing static factory methods on MockException. This is done by making the additional payload capabilities of IError obsolete. (We only need this for mock repository batch verification, but it turns out we can avoid that need by simply making the batch error messages more informative!)

A previous commit showed that even for aggregate mock verification,
we can simply concatenate error messages. Since `MockException` (like
any other exception type) already carries a message, as well as a
`reason` enum value, `MockException` provides all the payload we need
and we can drop the `IError` abstraction.

Instead of having many different `IError` types, we introduce simple
static factory methods in `MockException` that correspond to the
`MockExceptionReason` enum values. That way, we can pull the error
message building into a single place and clean up the throw sites.
@stakx stakx merged commit 37351bb into devlooped:master Jun 16, 2018
@stakx stakx deleted the mockexception branch June 16, 2018 10:57
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.

None yet

1 participant