Forked from Gustav-Simonsson/stacktrace_filter.erl
Last active
December 22, 2015 00:19
-
-
Save fjl/6388452 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, Args, Location}) when is_list(Args) -> | |
%% Replace args by arity, they might contain sensitive data | |
{Module, Function, length(Args), Location}; | |
({Module, Function, Arity, Location}) -> | |
{Module, Function, Arity, 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
This is good for R15, for R14 there is no location variable