Skip to content

Instantly share code, notes, and snippets.

@Gustav-Simonsson
Created August 30, 2013 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Gustav-Simonsson/6388318 to your computer and use it in GitHub Desktop.
Save Gustav-Simonsson/6388318 to your computer and use it in GitHub Desktop.
-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!"}).
@Gustav-Simonsson
Copy link
Author

Please see the fjl fork for a improved solution - which keeps the arity while filtering out the args.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment