[tarantool-patches] Re: [PATCH v1 3/3] box: extend ffi error object API

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Aug 9 22:27:01 MSK 2019



On 09/08/2019 01:33, Alexander Turenko wrote:
>>> +box_error_unwrap(box_error_t *error)
>>> +{
>>> +	struct error *reason = error->reason;
>>> +	assert(reason != NULL);
>>> +	diag_set_error(diag_get(), reason);
>>> +	error_unref(reason);
>>> +	error->reason = NULL;
>>> +	return reason;
>>
>> 7. Unwrap does not allow to unwrap a leaf error.
>> But there is no API to determine if the error is
>> leaf. So a user can't determine when to stop calling
>> unwrap.
>>
>> I am talking about C public API which you have changed
>> here. A user can't check error->reason != NULL before
>> calling box_error_unwrap.
>>
>> Moreover, it is inconsistent with Lua version. Lets
>> better return the argument when error->reason == NULL
>> in box_error_unwrap. Then a user of the C API would
>> just unwrap the stack until box_error_unwrap(e) == e.
>> Also it simplifies Lua version implementation.
> 
> Why not just return NULL when there is no a reason? It seems to be more
> logical for me.
> 

Perhaps. I don't mind, NULL is good too. But assertion is
not good.




More information about the Tarantool-patches mailing list