Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [redbean] add details to OnError Hook #1324

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tool/net/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ HOOKS
*). See functions like Route which asks redbean to do its default
thing from the handler.

OnError(status:int, message:string)
OnError(status:int, message:string, details:string)
If this function is defined and if any errors occurs in
OnHttpRequest() then this method will be called instead of displaying
the default error page. Useful if you need to display the error page
Expand Down
3 changes: 2 additions & 1 deletion tool/net/redbean.c
Original file line number Diff line number Diff line change
Expand Up @@ -2620,7 +2620,8 @@ static char *ServeErrorImpl(unsigned code, const char *reason,
lua_getglobal(L, "OnError");
lua_pushinteger(L, code);
lua_pushstring(L, reason);
if (LuaCallWithTrace(L, 2, 0, NULL) == LUA_OK) {
lua_pushstring(L, details);
if (LuaCallWithTrace(L, 3, 0, NULL) == LUA_OK) {
return CommitOutput(GetLuaResponse());
} else {
return ServeErrorImplDefault(code, reason, details);
Expand Down
Loading