Skip to content

Commit 8d5c1d4

Browse files
authored
[lua] remove luaL_error, which kill process (#19257)
1 parent 8bfc9a4 commit 8d5c1d4

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ THE SOFTWARE.
2323
****************************************************************************/
2424
#include "lua_downloader.h"
2525

26+
#include "cocos2d.h"
2627
#include "network/CCDownloader.h"
2728
#include "lua_extensions.h"
2829
#include <iostream>
@@ -57,7 +58,7 @@ static std::string get_field_string(lua_State *L, const char *field, const char
5758
lua_gettable(L, -2);
5859
if (lua_isnil(L, -1))
5960
{
60-
//luaL_error(L, "get_field_string: field '%s' no exists.", field);
61+
//CCLOGERROR("get_field_string: field '%s' no exists.", field);
6162
lua_pop(L, 1);
6263
return ret;
6364
}
@@ -117,7 +118,7 @@ static int lua_downloader_new(lua_State *L)
117118
if (argc >= 1) {
118119
//parse DownloaderHints
119120
if (!lua_istable(L, -1)) {
120-
luaL_error(L, "cc.Downloader.new: first argument should be table if set");
121+
CCLOGERROR("cc.Downloader.new: first argument should be table if set");
121122
return 0;
122123
}
123124
DownloaderHints hints;
@@ -155,7 +156,7 @@ static int lua_downloader_createDownloadDataTask(lua_State *L)
155156

156157
if (argc == 0)
157158
{
158-
luaL_error(L, "cc.Downloader.createDownloadDataTask parameter error");
159+
CCLOGERROR("cc.Downloader.createDownloadDataTask parameter error");
159160
return 0;
160161
}
161162

@@ -177,7 +178,7 @@ static int lua_downloader_createDownloadFileTask(lua_State *L)
177178

178179
if (argc < 2)
179180
{
180-
luaL_error(L, "cc.Downloader.createDownloadFileTask parameter error!");
181+
CCLOGERROR("cc.Downloader.createDownloadFileTask parameter error!");
181182
return 0;
182183
}
183184

@@ -195,7 +196,7 @@ static int lua_downloader_setOnFileTaskSuccess(lua_State *L)
195196
int argc = lua_gettop(L) - 1;
196197
Downloader *d = checkDownloader(L);
197198
if (argc != 1) {
198-
luaL_error(L, "cc.Downloader.setOnFileTaskSuccess parameter error!");
199+
CCLOGERROR("cc.Downloader.setOnFileTaskSuccess parameter error!");
199200
return 0;
200201
}
201202
luaL_argcheck(L, lua_isfunction(L, 2), 2, "should be a function");
@@ -209,7 +210,7 @@ static int lua_downloader_setOnFileTaskSuccess(lua_State *L)
209210
if (lua_pcall(L, 1, 0, 0) != 0)
210211
{
211212
lua_pop(L, 1); // remove callback or nil
212-
luaL_error(L, "cc.Downloader.setOnFileTaskSuccess invoke callback error!");
213+
CCLOGERROR("cc.Downloader.setOnFileTaskSuccess invoke callback error!");
213214
return;
214215
}
215216
}
@@ -225,7 +226,7 @@ static int lua_downloader_setOnTaskProgress(lua_State *L)
225226
Downloader *d = checkDownloader(L);
226227
int argc = lua_gettop(L) - 1;
227228
if (argc != 1) {
228-
luaL_error(L, "cc.Downloader.setOnTaskProgress parameter error!");
229+
CCLOGERROR("cc.Downloader.setOnTaskProgress parameter error!");
229230
return 0;
230231
}
231232
luaL_argcheck(L, lua_isfunction(L, 2), 2, "should be a function");
@@ -245,7 +246,7 @@ static int lua_downloader_setOnTaskProgress(lua_State *L)
245246
if (lua_pcall(L, 4, 0, 0) != 0)
246247
{
247248
lua_pop(L, 1); // remove callback or nil
248-
luaL_error(L, "cc.Downloader.setOnTaskProgress invoke callback error!");
249+
CCLOGERROR("cc.Downloader.setOnTaskProgress invoke callback error!");
249250
return;
250251
}
251252
}
@@ -261,7 +262,7 @@ static int lua_downloader_setOnTaskError(lua_State *L)
261262
Downloader *d = checkDownloader(L);
262263
int argc = lua_gettop(L) - 1;
263264
if (argc != 1) {
264-
luaL_error(L, "cc.Downloader.setOnTaskError parameter error!");
265+
CCLOGERROR("cc.Downloader.setOnTaskError parameter error!");
265266
return 0;
266267
}
267268
luaL_argcheck(L, lua_isfunction(L, 2), 2, "should be a function");
@@ -281,7 +282,7 @@ static int lua_downloader_setOnTaskError(lua_State *L)
281282
if (lua_pcall(L, 4, 0, 0) != 0)
282283
{
283284
lua_pop(L, 1); // remove callback or nil
284-
luaL_error(L, "cc.Downloader.setOnTaskError invoke callback error!");
285+
CCLOGERROR("cc.Downloader.setOnTaskError invoke callback error!");
285286
return;
286287
}
287288
}

0 commit comments

Comments
 (0)