From 072e1c51a1d67c6c80817ff1b6e7482ff67066e6 Mon Sep 17 00:00:00 2001 From: Marc Worrell Date: Fri, 6 May 2022 16:17:58 +0200 Subject: [PATCH] Ensure that an error page is rendered on an undefined function exception (#34) * Ensure that an error page is rendered on an undefined function exception * Pass reason, remove hard coded 'undef' --- src/cowmachine.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cowmachine.erl b/src/cowmachine.erl index 81d1d44..ebdba49 100644 --- a/src/cowmachine.erl +++ b/src/cowmachine.erl @@ -1,9 +1,9 @@ %% @author Marc Worrell -%% @copyright 2016-2019 Marc Worrell +%% @copyright 2016-2022 Marc Worrell %% %% @doc Cowmachine: webmachine middleware for Cowboy/Zotonic -%% Copyright 2016-2019 Marc Worrell +%% Copyright 2016-2022 Marc Worrell %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -115,7 +115,7 @@ request_1(Controller, Req, Env, Options, Context) -> log(#{ at => ?AT, level => error, code => 500, text => "Unexpected exception", class => Class, reason => Reason, stack => Stacktrace}, Req), - {stop, cowboy_req:reply(500, Req)} + handle_stop_request(500, Site, {throw, {Reason, Stacktrace}}, Req, Env, State, Context) end. % @todo add the error controller as an application env, if not defined then just terminate with the corresponding error code.