Browse Source

n2o_error to n4u_error (for render with new catch/3 Stacktrace)

221V 3 years ago
parent
commit
592582e1a0
4 changed files with 21 additions and 31 deletions
  1. 1 1
      ebin/n4u.app
  2. 0 29
      src/handlers/n2o_error.erl
  3. 19 0
      src/handlers/n4u_error.erl
  4. 1 1
      src/wf.erl

+ 1 - 1
ebin/n4u.app

@@ -2,7 +2,7 @@
   {description, "N4U WebSocket Application Server"},
   {vsn, "4.4.20"},
   {applications, [kernel, stdlib, asn1, public_key, ssl, crypto, ranch, cowboy, fs, active, sh, gproc, nitro]},
-  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n2o_proto, n2o_relay, n2o_error, n2o_io, n2o_log, n2o_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n4u_client, n2o_file, n2o_heart, n2o_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
+  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n2o_proto, n2o_relay, n4u_error, n2o_io, n2o_log, n2o_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n4u_client, n2o_file, n2o_heart, n2o_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
   {registered, [n4u_sup]},
   {mod, {n4u_app, []}},
   {env, []}

+ 0 - 29
src/handlers/n2o_error.erl

@@ -1,29 +0,0 @@
--module(n2o_error).
--include_lib("n4u/include/n4u.hrl").
--compile([export_all, nowarn_export_all]).
--export([error_page/2]).
-
-% Plain Text Error Page Render
-% Here is sample
-%
-% ERROR:  error:badarith
-%
-% STACK:  index:body/0:18
-%         index:main/0:8
-%         n4u_document:run/1:15
-
-stack(Error, Reason) ->
-    Stacktrace = [case A of
-         { Module,Function,Arity,Location} ->
-             { Module,Function,Arity,proplists:get_value(line, Location) };
-         Else -> Else end
-    || A <- erlang:get_stacktrace()],
-    [Error, Reason, Stacktrace].
-
-
-error_page(Class,Error) ->
-    io_lib:format("ERROR:  ~w:~w~n~n",[Class,Error]) ++
-    "STACK: " ++
-    [ wf:render([io_lib:format("\t~w:~w/~w:~w",
-        [ Module,Function,Arity,proplists:get_value(line, Location) ]),"\n"])
-    ||  { Module,Function,Arity,Location} <- erlang:get_stacktrace() ].

+ 19 - 0
src/handlers/n4u_error.erl

@@ -0,0 +1,19 @@
+-module(n4u_error).
+
+-export([error_page/3]).
+
+% Plain text error page render
+%
+% ERROR:  error:badarith
+%
+% STACK:  index:body/0 : line 18
+%         index:main/0 : line 8
+%         n4u_document:run/1 : line 15
+
+error_page(Class, Error, Stacktrace) ->
+  io_lib:format("ERROR:  ~p:~p~n~n", [Class, Error]) ++
+    "STACK: " ++
+    [ nitro:render([io_lib:format("\t~p:~p/~p : line ~p",
+        [Module, Function, Arity, proplists:get_value(line, Location) ]), "\n"])
+    ||  {Module, Function, Arity, Location} <- Stacktrace ].
+

+ 1 - 1
src/wf.erl

@@ -100,7 +100,7 @@ depickle(SerializedData, TTLSeconds) -> ?PICKLER:depickle(SerializedData, TTLSec
 % Error handler wf:error_page
 
 -ifndef(ERRORING).
--define(ERRORING, (wf:config(n2o,erroring,n2o_error))).
+-define(ERRORING, (application:get_env(n4u, erroring, n4u_error))).
 -endif.
 
 stack(Error, Reason)    -> ?ERRORING:stack(Error, Reason).