Skip to content

Commit adfacc7

Browse files
committed
Add more verbosity to function call errors in reflect module.
1 parent adf1ebb commit adfacc7

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

source/reflect/source/reflect_function.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,24 +293,44 @@ value function_metadata(function func)
293293

294294
function_return function_call(function func, function_args args, size_t size)
295295
{
296-
if (func != NULL && args != NULL)
296+
if (func == NULL)
297297
{
298-
if (func->interface != NULL && func->interface->invoke != NULL)
299-
{
300-
if (func->name == NULL)
301-
{
302-
log_write("metacall", LOG_LEVEL_DEBUG, "Invoke annonymous function with args <%p>", (void *)args);
303-
}
304-
else
305-
{
306-
log_write("metacall", LOG_LEVEL_DEBUG, "Invoke function (%s) with args <%p>", func->name, (void *)args);
307-
}
298+
log_write("metacall", LOG_LEVEL_ERROR, "Invalid function call, function pointer is null");
308299

309-
return func->interface->invoke(func, func->impl, args, size);
310-
}
300+
return NULL;
311301
}
312302

313-
return NULL;
303+
if (args == NULL)
304+
{
305+
log_write("metacall", LOG_LEVEL_ERROR, "Invalid function call, arguments are null");
306+
307+
return NULL;
308+
}
309+
310+
if (func->interface == NULL)
311+
{
312+
log_write("metacall", LOG_LEVEL_ERROR, "Invalid function call, function interface is null");
313+
314+
return NULL;
315+
}
316+
317+
if (func->interface->invoke == NULL)
318+
{
319+
log_write("metacall", LOG_LEVEL_ERROR, "Invalid function call, function interface invoke method is null");
320+
321+
return NULL;
322+
}
323+
324+
if (func->name == NULL)
325+
{
326+
log_write("metacall", LOG_LEVEL_DEBUG, "Invoke annonymous function with args <%p>", (void *)args);
327+
}
328+
else
329+
{
330+
log_write("metacall", LOG_LEVEL_DEBUG, "Invoke function (%s) with args <%p>", func->name, (void *)args);
331+
}
332+
333+
return func->interface->invoke(func, func->impl, args, size);
314334
}
315335

316336
function_return function_await(function func, function_args args, size_t size, function_resolve_callback resolve_callback, function_reject_callback reject_callback, void * context)

0 commit comments

Comments
 (0)