[FFmpeg-devel] [RFC] Advanced Error Codes
Michael Niedermayer
michael at niedermayer.cc
Thu Jul 3 18:52:05 EEST 2025
Hi
On Thu, Jul 03, 2025 at 10:56:39AM +0200, Nicolas George wrote:
> Michael Niedermayer (HE12025-07-02):
[...]
> To be clear, you suggest, IIUC:
>
> - The developer registers the error code.
> - The developer writes the explanation for the error when registering
> the error code.
> - The developer uses the error code when returning the error.
> - The user gets an error code.
> - The user looks up the error code to get the explanation for the error.
no, just:
return av_adv_err_new(AVERROR_INVALIDDATA, "Garbled foobar data", "Foo triangle quantum decoder"
__FILE__, __LINE__, NULL, "Whaetver you like %s", favorite_food);
teh return type is int64_t here
this also cannot fail as it allocates nothing
it also needs no context but would use a mutex or thread local storage
the message length would be bound by a maximum, set at compile time
and the number of messages that this keeps track of also would be
bound by a maximum, set at compile time
>
> What I propose:
>
> - The developer writes the explanation for the error when returning the
> error.
> - The user gets the explanation for the error directly.
>
> Or, in terms of code:
>
> return AVERROR_MESSAGE(ctx, "Garbled foobar data at offset ${offset}",
> "offset", ctx->offset, NULL);
I am not sure if passing a context around is going to find the volunteers
to implement and maintain. Also it has a performance impact for small and
lightweight functions.
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
For a strong democracy, genuine criticism is necessary, allegations benefit
noone, they just cause unnecessary conflicts. - Narendra Modi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250703/6b273f56/attachment.sig>
More information about the ffmpeg-devel
mailing list