[erlang-questions] is empty catch statement possible?

Lukas Larsson lukas@REDACTED
Thu Feb 9 19:46:07 CET 2012


iirc you should be able to do:

try
   something
after
  io:format("hello after",[])
end.

Not sure how lager works, but if it keeps an external state for the
logging level it will not be reset if the process executing the try
catch is killed due to an exit msg.

Lukas

2012/2/9 Motiejus Jakštys <desired.mta@REDACTED>:
> Whoops, a small mistake in code. Fixed version:
>
> -define(silent(Level, Expr), (fun() ->
>                 __Lager_OldLevel = lager:get_loglevel(lager_console_backend),
> +                lager:set_loglevel(lager_console_backend, Level),
>                 try
>                     fun() -> Expr end
>                 catch
>                     throw:'$__should_never_be_thrown' -> ok
>                 after
>                     leger:set_loglevel(lager_console_backend, __Lager_OldLevel)
>                 end
>         end)()).
>
> Motiejus
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list