Skip to content

Instantly share code, notes, and snippets.

@soranoba
Created May 4, 2018 06:46
Show Gist options
  • Save soranoba/054a8e236d398d7d5d3a3ecdeb1ab814 to your computer and use it in GitHub Desktop.
Save soranoba/054a8e236d398d7d5d3a3ecdeb1ab814 to your computer and use it in GitHub Desktop.
migration OTP21
-ifdef('GET_STACKTRACE_AVAILABLE').
-define(CATCH_MATCH(__R), __R).
-define(GET_STACKTRACE(), erlang:get_stacktrace()).
-else.
-define(CATCH_MATCH(__R), __R:__StackTrace).
-define(GET_STACKTRACE(), __StackTrace).
-endif.
{erl_opts, [
{platform_define, "^(R|1|20)", 'GET_STACKTRACE_AVAILABLE'}
]}.
catch
- error:{badmatch, {error, {Reason, [StackItem]}}} ->
- erlang:raise(error, Reason, [StackItem | erlang:get_stacktrace()])
+ error:?CATCH_MATCH({badmatch, {error, {Reason, [StackItem]}}}) ->
+ erlang:raise(error, Reason, [StackItem | ?GET_STACKTRACE()])
end.
@soranoba
Copy link
Author

soranoba commented May 4, 2018

sample.erlの修正前はsile/jsoneから.

@soranoba
Copy link
Author

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