Skip to content

Commit ad0a7c6

Browse files
authored
[redbean] Add details to OnError Hook (#1324)
The details of the error was missing, this PR add details to the OnError hook so we can now get why the error occurs
1 parent 1312f60 commit ad0a7c6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

tool/net/help.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ HOOKS
569569
*). See functions like Route which asks redbean to do its default
570570
thing from the handler.
571571

572-
OnError(status:int, message:string)
572+
OnError(status:int, message:string, details:string)
573573
If this function is defined and if any errors occurs in
574574
OnHttpRequest() then this method will be called instead of displaying
575575
the default error page. Useful if you need to display the error page

tool/net/redbean.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,8 @@ static char *ServeErrorImpl(unsigned code, const char *reason,
26202620
lua_getglobal(L, "OnError");
26212621
lua_pushinteger(L, code);
26222622
lua_pushstring(L, reason);
2623-
if (LuaCallWithTrace(L, 2, 0, NULL) == LUA_OK) {
2623+
lua_pushstring(L, details);
2624+
if (LuaCallWithTrace(L, 3, 0, NULL) == LUA_OK) {
26242625
return CommitOutput(GetLuaResponse());
26252626
} else {
26262627
return ServeErrorImplDefault(code, reason, details);

0 commit comments

Comments
 (0)