aroemers / mount-lite

mount, but different and light
https://cljdoc.org/d/functionalbytes/mount-lite/
Eclipse Public License 1.0
102 stars 8 forks source link

Throw Error when accessing an unstarted state #17

Closed dryewo closed 6 years ago

dryewo commented 6 years ago

Hi Arnout,

I'm quite enjoying mount-lite now :) I'm developing several services based on it, and I've encountered a minor issue.

When I write my unit tests, I sometimes start the application excluding some states that perform side effects (like accessing AWS). When I (erroneously) forget to mock some function that uses those states, the @ throws an ExceptionInfo "state xxx not started".

However, if that call is wrapped in a (try ... (catch Exception _)), this error does not propagate to the top level, hiding the error from the test runner.

I imagine that this could be easily solved by throwing Error (which does not inherit Exception, but Throwable). It also seems the right thing to do, as state configuration problems are always programmer's errors and are not meant to be caught like ExceptionInfo.

Here is my humble PR to implement this proposal. Please let me know what you think.

Thanks in advance.

aroemers commented 6 years ago

Thank you for this; I think it's a good addition.

Also, sorry for not responding earlier. Do you need a release very soon?

dryewo commented 6 years ago

Thanks for merging! No, it's not urgent for me. Please release at your discretion.