Last active
November 21, 2020 23:09
-
-
Save WLSF/e25338d8267ca4b2176fbdc35081fc10 to your computer and use it in GitHub Desktop.
Trying decorators to check if implicit tracing would be a good idea.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Reports do | |
use Decorator.Define, [trace: 0] | |
def trace(body, context) do | |
quote do | |
try do | |
unquote(body) | |
rescue | |
e -> | |
IO.puts("Erro: " <> e.message) | |
IO.puts("Stack: " <> inspect(__STACKTRACE__)) | |
end | |
end | |
end | |
end | |
defmodule A do | |
use Reports | |
@decorate trace() | |
def division_by_zero(a), do: a / 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment