Skip to content

Commit

Permalink
[Minor] Slightly improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Sep 9, 2023
1 parent 0b51255 commit f5e3fbe
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/lua/lua_http.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*-
* Copyright 2016 Vsevolod Stakhov
/*
* Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -677,6 +677,8 @@ lua_http_request(lua_State *L)
msg = rspamd_http_message_from_url(url);

if (msg == NULL) {
luaL_unref(L, LUA_REGISTRYINDEX, cbref);
msg_err("cannot create HTTP message from url %s", url);
lua_pushboolean(L, FALSE);
return 1;
}
Expand All @@ -687,6 +689,12 @@ lua_http_request(lua_State *L)
url = luaL_checkstring(L, -1);
lua_pop(L, 1);

if (url == NULL) {
msg_err("cannot create HTTP message without url");
lua_pushboolean(L, FALSE);
return 1;
}

lua_pushstring(L, "callback");
lua_gettable(L, 1);
if (url == NULL || lua_type(L, -1) != LUA_TFUNCTION) {
Expand Down Expand Up @@ -763,7 +771,7 @@ lua_http_request(lua_State *L)

msg = rspamd_http_message_from_url(url);
if (msg == NULL) {
msg_err("cannot create HTTP message from url %s", url);
msg_err_task_check("cannot create HTTP message from url %s", url);
lua_pushboolean(L, FALSE);
return 1;
}
Expand Down

0 comments on commit f5e3fbe

Please sign in to comment.