Skip to content

Raise exceptions on incorrect hook definition #62

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

Merged
merged 1 commit into from
May 23, 2020

Conversation

gaeljw
Copy link
Member

@gaeljw gaeljw commented May 23, 2020

Aims to fix #60

If an incorrect hook is defined and this cannot be caught at compile time, then an exception is raised at runtime with a message similar to this:

Some hooks are not defined properly:
 - IncorrectClassHooksDefinition.scala:11 (BEFORE)
 - IncorrectClassHooksDefinition.scala:14 (BEFORE_STEP)
 - IncorrectClassHooksDefinition.scala:17 (AFTER)
 - IncorrectClassHooksDefinition.scala:20 (AFTER_STEP)

This can be caused by defining hooks where the body returns a Int or String rather than Unit.

For instance, the following code:

  Before {
    someInitMethodReturningInt()
  }

Should be replaced with:

  Before {
    someInitMethodReturningInt()
    ()
  }

This PR also include a small refactoring of the GlueRegistry to use immutable types with private var rather than mutable types with public val. The former avoid to leak a mutable type outside.

@gaeljw gaeljw force-pushed the error-if-hooks-undefined branch from 54ecea4 to 4f8c823 Compare May 23, 2020 14:57
@gaeljw gaeljw merged commit 9ec2f94 into master May 23, 2020
@gaeljw gaeljw deleted the error-if-hooks-undefined branch May 23, 2020 15:14
…efined

And use immutable types with var rather than mutable types with val (ScalaDslRegistry)
@mpkorstanje
Copy link
Contributor

This is really cool!

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.

Hooks can silently be ignored if body returns an Int
2 participants