Next: , Previous: GstElement, Up: Top


11 GstGError

Categorized error messages

11.1 Overview

GStreamer elements can throw non-fatal warnings and fatal errors. Higher-level elements and applications can programatically filter the ones they are interested in or can recover from, and have a default handler handle the rest of them.

The rest of this section will use the term error to mean both (non-fatal) warnings and (fatal) errors; they are treated similarly.

Errors from elements are the combination of a <g-error> and a debug string. The <g-error> contains: - a domain type: CORE, LIBRARY, RESOURCE or STREAM - a code: an enum value specific to the domain - a translated, human-readable message - a non-translated additional debug string, which also contains - file and line information

Elements do not have the context required to decide what to do with errors. As such, they should only inform about errors, and stop their processing. In short, an element doesn't know what it is being used for.

It is the application or compound element using the given element that has more context about the use of the element. Errors can be received by listening to the <gst-bus> of the element/pipeline for <gst-message> objects with the type ‘GST_MESSAGE_ERROR’ or ‘GST_MESSAGE_WARNING’. The thrown errors should be inspected, and filtered if appropriate.

An application is expected to, by default, present the user with a dialog box (or an equivalent) showing the error message. The dialog should also allow a way to get at the additional debug information, so the user can provide bug reporting information.

A compound element is expected to forward errors by default higher up the hierarchy; this is done by default in the same way as for other types of <gst-message>.

When applications or compound elements trigger errors that they can recover from, they can filter out these errors and take appropriate action. For example, an application that gets an error from xvimagesink that indicates all XVideo ports are taken, the application can attempt to use another sink instead.

Elements throw errors using the <gst-element-error> convenience macro:

     
         GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
           (_("No file name specified for reading.")), (NULL));
     

Things to keep in mind:

Last reviewed on 2006-09-15 (0.10.10)

11.2 Usage

— Function: gst-error-get-message (domain unsigned-int) (code int)   (ret mchars)

Get a string describing the error message in the current locale.

domain
the GStreamer error domain this error belongs to.
code
the error code belonging to the domain.
ret
a newly allocated string describing the error message in the current locale.