Fredrik de Vibe
unread,Jan 17, 2014, 5:32:34 AM1/17/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to chica...@googlegroups.com
Hi,
If a template calls a function that crashes, e.g. with a function_clause
or a case_clause error, that error is currently squelched, the http
request is terminated, and the only thing visible in the logs is
something like
[error] Error in process <0.1337.0> on node 'appname@host' with exit
value: {{case_clause,closed},[{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]}
meaning that cowboy doesn't have any way to handle this case (which
makes sense, I guess).
Now, if, for example, errors from
boss_web_controller_render:render_with_template are caught in
boss_web_controller_render:render_view, it is possible to intercept such
errors and handle them, something along the lines of
try render_with_template(Controller, Template, AppInfo, RequestContext,
Variables, Headers, Req, BossFlash,
SessionData, Module, TemplateAdapter)
catch error:Error ->
Trace = erlang:get_stacktrace(),
lager:error(
"Runtime error while rendering template ~p: ~p, stack: ~p",
[Template, Error, Trace]),
render_error(Error, Trace, AppInfo, RequestContext)
end;
So far, everything is fine, but I wonder if this is not a somewhat
deeper architectural question. My erlang knowledge is limited, but
AFAICT, what happens here is that the boss process that handles
rendering (boss_web?) crashes and the cowboy process doesn't have any
way to clean up. Are there other places where a boss application can
crash and cause similar problems, and should such crashes be handled in
a more generic way somewhere else? Thoughts?
Thanks,
- Fredrik