Skip to content

Raise may call an atom - undefined module #76

@tomdos

Description

@tomdos

There is an issue in catching an exit here https://github.com/joaomdmoura/machinery/blob/master/lib/machinery.ex#L95

The raise expect a module or a string. However it may get an atom and Elixir will try to call exception/1 from that atom which obviously fails.

How to reproduce it:

Machinery.transition_to(A, :b_parma, :c_param)

Output:

17:15:41.494 [error] GenServer Machinery.Transitions terminating
** (UndefinedFunctionError) function :b_parma._machinery_initial_state/0 is undefined (module :b_parma is not available)
    :b_parma._machinery_initial_state()
    (machinery) lib/machinery/transitions.ex:24: Machinery.Transitions.handle_call/3
    (stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:690: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.1595.0>): {:run, A, :b_parma, :c_param}
** (UndefinedFunctionError) function :undef.exception/1 is undefined (module :undef is not available)
    :undef.exception([])
    (machinery) lib/machinery.ex:113: Machinery.transition_to/3

As you can see I used undefined module and this gets to raise which tries to call :undef.exception/1 which is undefined as well.

Maybe as a quick fix changing raise to throw may work or removing catching at all?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions