[vlc-devel] [vlc-commits] lua: use vlc_strerror_c()
Rémi Denis-Courmont
remi at remlab.net
Mon May 20 14:55:19 CEST 2019
Hi,
I don't think we should have one ENOx error code for each and every type of object. Error codes are a trade-off. For detailed diagnostic, we won't escape from logs.
Le 20 mai 2019 15:11:23 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>On 2019-05-20 13:58, Rémi Denis-Courmont wrote:
>> Hi,
>>
>> Entry not found is pretty much what all those error code mean,
>actually.
>> The loss of type-specificity is old (and you seem to have contributed
>to
>
>I plead guilty. But having more detailed errors is probably what would
>should use. And yes, we should use them more and properly and forward
>then than just ending up with VLC_EGENERIC everywhere.
>
>> it...). But well, here, if we don't remove Lua RC, then we should
>simply
>> have it print command specific errors rather than vague generic
>messages
>> like this or the previous code does.
>>
>> Le 20 mai 2019 09:44:42 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> a
>écrit :
>>
>> On 2019-05-19 19:20, Rémi Denis-Courmont wrote:
>>
>> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net>
>|
>> Sun May 19 20:13:33 2019 +0300|
>> [161832532aa60c2f06798f79c1898680f39a2c1d] | committer: Rémi
>> Denis-Courmont
>>
>> lua: use vlc_strerror_c()
>>
>>
>http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=161832532aa60c2f06798f79c1898680f39a2c1d
>>
>>
>------------------------------------------------------------------------
>> modules/lua/libs/misc.c | 23 ++++++++++++++++++++++-
>> 1 file changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/modules/lua/libs/misc.c
>b/modules/lua/libs/misc.c
>> index b251eb7f22..25f44c3047 100644
>> --- a/modules/lua/libs/misc.c
>> +++ b/modules/lua/libs/misc.c
>> @@ -33,6 +33,7 @@
>> # include "config.h"
>> #endif
>>
>> +#include <errno.h>
>> #include <math.h>
>> #include <stdlib.h>
>>
>> @@ -84,7 +85,27 @@ vlc_object_t * vlclua_get_this( lua_State
>*L )
>> int vlclua_push_ret( lua_State *L, int i_error )
>> {
>> lua_pushnumber( L, i_error );
>> - lua_pushstring( L, vlc_error_string( i_error ) );
>> +
>> + int err;
>> +
>> + switch( i_error )
>> + {
>> + case VLC_SUCCESS: err = 0; break;
>> + case VLC_ENOMEM: err = ENOMEM; break;
>> + case VLC_ETIMEOUT: err = ETIMEDOUT; break;
>> + case VLC_EBADVAR: err = EINVAL; break;
>> + case VLC_ENOMOD: err = ENOENT; break;
>>
>>
>> This is not equivalent to ENOENT.
>>
>> + case VLC_ENOOBJ: err = ENOENT; break;
>>
>>
>> This is not equivalent to ENOENT.
>>
>> + case VLC_ENOVAR: err = ENOENT; break;
>>
>>
>> This is not equivalent to ENOENT.
>>
>> + case VLC_EGENERIC:
>> + lua_pushstring( L, "generic error" );
>> + return 2;
>> + default:
>> + lua_pushstring( L, "unknown error" );
>> + return 2;
>> + }
>> +
>> + lua_pushstring( L, vlc_strerror_c(err) );
>> return 2;
>> }
>>
>------------------------------------------------------------------------
>> vlc-commits mailing list
>> vlc-commits at videolan.org
>> https://mailman.videolan.org/listinfo/vlc-commits
>>
>>
>------------------------------------------------------------------------
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>>
>>
>> --
>> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez
>excuser
>> ma brièveté.
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190520/50297e1f/attachment.html>
More information about the vlc-devel
mailing list