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

ExceptionResult is now Typed and withCause and withMessage are now fluent #38

Merged
merged 2 commits into from
Apr 5, 2017

Conversation

vjames19
Copy link
Contributor

@vjames19 vjames19 commented Apr 4, 2017

Typed ExceptionResult

Currently I'm working with Custom Exceptions that have properties like status codes and I have the need to further validate those properties

            class CustomException(val code: Int) : Exception("code is $code")

            on("throwing an exception of the right type") {
                it("should return the exception result with the given type") {

                    val func = { throw CustomException(10) }

                    func.shouldThrowTheException(CustomException::class).exception.code.shouldEqualTo(10)
                }
            }

Fluent withCause and withMessage

The change now allows you to do:

val func = { throw IllegalArgumentException("hello", IOException()) }
func shouldThrowTheException IllegalArgumentException::class withCause IOException::class withMessage "hello"

Let me know if there is anything else I need to add.

@MarkusAmshove
Copy link
Owner

This looks awesome, thank you!

@MarkusAmshove MarkusAmshove merged commit 3be2ebe into MarkusAmshove:master Apr 5, 2017
@MarkusAmshove
Copy link
Owner

I've released v1.19 with your change so you can start using it 👍

@vjames19
Copy link
Contributor Author

vjames19 commented Apr 6, 2017

@MarkusAmshove thank you! Already using it 👍

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.

2 participants