Skip to content

Instantly share code, notes, and snippets.

@sstrigler
Created January 26, 2016 14:12
Show Gist options
  • Save sstrigler/34f72edb8d1134e9de5c to your computer and use it in GitHub Desktop.
Save sstrigler/34f72edb8d1134e9de5c to your computer and use it in GitHub Desktop.
-module(foo_handler).
-callback handle_message(binary(), map()) ->
ok | {ok, term()} | {error, term()}.
-export([validate_and_handle/2]).
-spec validate_and_handle(atom(), binary()) ->
ok | {ok, term()} | {error, term()}.
validate_and_handle(Module, Message) ->
case foo:validate(Message) of
{ok, Data} ->
Module:handle_message(Data);
Error ->
Error
end.
@sstrigler
Copy link
Author

elvis would complain with

src/foo_handler.erl [FAIL]

  • invalid_dynamic_call
    • Remove the dynamic function call on line 13. Only modules that define callbacks should make dynamic calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment