ecto_hooks icon indicating copy to clipboard operation
ecto_hooks copied to clipboard

Scope the rescue clause to only catch undefined ecto hooks functions.

Open jakeprem opened this issue 2 years ago • 1 comments

I did this in the Web UI and haven't run it yet so I'm not sure if the implementation is 100% correct, but I wanted to capture the problem and general idea of a solution.

We should be able to add some unit tests that verify the behavior.

jakeprem avatar Mar 30 '23 18:03 jakeprem

I don't think the exception pattern clauses can have real pattern matches in them.

I think we should definitely do this, but let's just do an if or case inside the exception handler clause like:

rescue
  e in [UndefinedFunctionError, ...] ->
    if e.function == ^hook do
      :ok
    else
      reraise e, stacktrace: __STACKTRACE__
    end

vereis avatar Mar 31 '23 10:03 vereis