[FFmpeg-devel] [RFC] Internal error messages

Nicolas George george at nsup.org
Thu Jun 17 12:52:09 EEST 2021


Diederick C. Niehorster (12021-06-12):
> One thing to add is this: Errors are often propagated back through
> various layers of function calls. Some next level may:
> 1. decide something is not an error/should be ignored. It should be
> able to unset the current error (if it was set, so something like
> av_error_clear(int error_code) which only unsets if error code
> matches)
> 2. wish to add information about the error. Often useful info is not
> available at the site where the error is generated, but only (several)
> levels up. Errors should be set where they are generated, and info can
> optionally be added as the stack is traversed back to the user's call.
> Kinda like catch and rethrow with added info/std::nested_exception in
> C++. something like
> av_error_set(ctx, optional_additional_error_code,
>     "additional formatted error string, like in the usage example");

Thanks for the feedback. This is definitely something to keep in mind
when the time comes to implement that.

> > > For compatibility, av_log(ctx, ...) will not only print to stderr, but also
> > > keep the last line(s) of log in the AVErrorStatus buffer in ctx, so that
> > > code that still does the good old:

> > What I'm a little iffy on is this last part, mostly because a lot of code in
> > FFmpeg just returns an error without any av_log call, so the current error
> > buffer in the context will at best be unrelated, or at worst, really
> > misleading to the user.

> Agreed, this can't work consistently, I'd skip it. And it highlights
> also that there may be stale errors returned through av_error_get().

I think this is too early to decide about this. You are both right, if
we include my last suggestion, routing log to internal error messages,
then we may end up with stale or irrelevant error messages.

But on the other hand, we will not wall the whole code base to replace
av_log() with av_error_set(), and we still want relevant error messages
from these parts of the code.

This is not an uncommon situation: we have an old API, we want to fit it
into a new, more powerful API, it always raises little problems. And the
solution is usually not an actual solution but rather a set of
heuristics.

So I guess in the final version, we will look for a way to route the
interesting log messages to the internal error message, and we will need
to tweak it to select the really interesting messages and leave out the
irrelevant.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210617/b1afa6bb/attachment.sig>


More information about the ffmpeg-devel mailing list