]> granicus.if.org Git - ejabberd/commitdiff
Fix exception formatting on old Erlang
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Fri, 14 Jun 2019 13:58:39 +0000 (16:58 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Fri, 14 Jun 2019 13:58:39 +0000 (16:58 +0300)
rebar.config
src/misc.erl

index 4798f20f688c053e72cef224cb3ebc1ded1e2dd8..5fb25a029c5ed2f49c2fd4517bed42348609739c 100644 (file)
@@ -96,6 +96,7 @@
             {if_var_true, elixir, {d, 'ELIXIR_ENABLED'}},
             {if_var_true, new_sql_schema, {d, 'NEW_SQL_SCHEMA'}},
             {if_var_true, hipe, native},
+           {if_have_fun, {erl_error, format_exception, 6}, {d, 'HAVE_ERL_ERROR'}},
             {src_dirs, [src,
                         {if_var_true, tools, tools},
                         {if_var_true, elixir, include}]}]}.
index 0ebcbef78885a9e627b4b6d1aaab53ec916956e7..16e4122b556198fa19bd4e6d07903d6461bfde20 100644 (file)
@@ -482,6 +482,7 @@ peach(Fun, [_,_|_] = List) ->
 peach(Fun, List) ->
     lists:foreach(Fun, List).
 
+-ifdef(HAVE_ERL_ERROR).
 format_exception(Level, Class, Reason, Stacktrace) ->
     erl_error:format_exception(
       Level, Class, Reason, Stacktrace,
@@ -489,6 +490,15 @@ format_exception(Level, Class, Reason, Stacktrace) ->
       fun(Term, I) ->
              io_lib:print(Term, I, 80, -1)
       end).
+-else.
+format_exception(Level, Class, Reason, Stacktrace) ->
+    lib:format_exception(
+      Level, Class, Reason, Stacktrace,
+      fun(_M, _F, _A) -> false end,
+      fun(Term, I) ->
+             io_lib:print(Term, I, 80, -1)
+      end).
+-endif.
 
 -spec parse_ip_mask(binary()) -> {ok, {inet:ip4_address(), 0..32}} |
                                 {ok, {inet:ip6_address(), 0..128}} |