[erlang-questions] is empty catch statement possible?

Motiejus Jakštys desired.mta@REDACTED
Thu Feb 9 19:37:03 CET 2012


Hello,
consider this macro:

-define(silent(Level, Expr), (fun() ->
                __Lager_OldLevel = lager:get_loglevel(lager_console_backend),
                try 
                    fun() -> Expr end 
                catch
                    throw:'$__should_never_be_thrown' -> ok
                after
                    leger:set_loglevel(lager_console_backend, __Lager_OldLevel)
                end 
        end)()).


1) does it do what I expect? I want log level to be restored in _any_ case.
2) Is there a way to avoid the stub throw:Atom statement?

Thanks
Motiejus



More information about the erlang-questions mailing list