Created
August 30, 2013 10:04
-
-
Save Gustav-Simonsson/6388318 to your computer and use it in GitHub Desktop.
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
-module(stacktrace_filter). | |
-compile(export_all). | |
t() -> | |
try | |
sensitive_data_function() | |
catch | |
Error:Reason -> | |
{Error, Reason, erlang:get_stacktrace()} | |
end. | |
t2() -> | |
try | |
sensitive_data_function() | |
catch | |
Error:Reason -> | |
ST = erlang:get_stacktrace(), | |
FilteredST = filter_stacktrace(ST), | |
{Error, Reason, FilteredST} | |
end. | |
filter_stacktrace(ST) -> | |
Filter = | |
fun({Module, Function, _ArityOrArgs, Location}) -> | |
%% Skip ArityOrArgs, as if it contains the args, it may | |
%% contain sensitive data., | |
{Module, Function, Location} | |
end, | |
lists:map(Filter, ST). | |
sensitive_data_function() -> | |
lists:concat([secret], {"top_secret stuff!"}). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please see the fjl fork for a improved solution - which keeps the arity while filtering out the args.