2004-01-18 21:36:20 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2003> David A. Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2004-01-18 21:36:20 +00:00
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-08-31 14:08:45 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gsterror
|
|
|
|
* @short_description: Categorized error messages
|
2005-11-18 18:55:24 +00:00
|
|
|
* @see_also: #GstMessage
|
2005-08-31 14:08:45 +00:00
|
|
|
*
|
2005-11-18 18:55:24 +00:00
|
|
|
* GStreamer elements can throw non-fatal warnings and fatal errors.
|
2013-12-07 14:38:19 +00:00
|
|
|
* Higher-level elements and applications can programmatically filter
|
2005-11-18 18:55:24 +00:00
|
|
|
* 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 <quote>error</quote>
|
|
|
|
* to mean both (non-fatal) warnings and (fatal) errors; they are treated
|
|
|
|
* similarly.
|
|
|
|
*
|
|
|
|
* Errors from elements are the combination of a #GError and a debug string.
|
|
|
|
* The #GError 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
|
2006-09-15 21:30:00 +00:00
|
|
|
* has more context about the use of the element. Errors can be received by
|
|
|
|
* listening to the #GstBus of the element/pipeline for #GstMessage objects with
|
|
|
|
* the type %GST_MESSAGE_ERROR or %GST_MESSAGE_WARNING. The thrown errors should
|
2005-11-18 18:55:24 +00:00
|
|
|
* 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 #GstMessage.
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*
|
|
|
|
* <example>
|
|
|
|
* <title>Throwing an error</title>
|
|
|
|
* <programlisting>
|
|
|
|
* GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
|
|
|
|
* (_("No file name specified for reading.")), (NULL));
|
|
|
|
* </programlisting>
|
|
|
|
* </example>
|
|
|
|
*
|
|
|
|
* Things to keep in mind:
|
|
|
|
* <itemizedlist>
|
|
|
|
* <listitem><para>Don't go off inventing new error codes. The ones
|
|
|
|
* currently provided should be enough. If you find your type of error
|
|
|
|
* does not fit the current codes, you should use FAILED.</para></listitem>
|
|
|
|
* <listitem><para>Don't provide a message if the default one suffices.
|
2014-05-29 21:54:34 +00:00
|
|
|
* this keeps messages more uniform. Use (%NULL) - not forgetting the
|
2005-11-18 18:55:24 +00:00
|
|
|
* parentheses.</para></listitem>
|
|
|
|
* <listitem><para>If you do supply a custom message, it should be
|
|
|
|
* marked for translation. The message should start with a capital
|
2006-09-02 13:40:41 +00:00
|
|
|
* and end with a period. The message should describe the error in short,
|
|
|
|
* in a human-readable form, and without any complex technical terms.
|
|
|
|
* A user interface will present this message as the first thing a user
|
|
|
|
* sees. Details, technical info, ... should go in the debug string.
|
|
|
|
* </para></listitem>
|
2014-05-29 21:54:34 +00:00
|
|
|
* <listitem><para>The debug string can be as you like. Again, use (%NULL)
|
2005-11-18 18:55:24 +00:00
|
|
|
* if there's nothing to add - file and line number will still be
|
|
|
|
* passed. #GST_ERROR_SYSTEM can be used as a shortcut to give
|
|
|
|
* debug information on a system call error.</para></listitem>
|
|
|
|
* </itemizedlist>
|
2005-08-31 14:08:45 +00:00
|
|
|
*/
|
2004-01-18 21:36:20 +00:00
|
|
|
|
2014-09-25 19:21:09 +00:00
|
|
|
/* FIXME 2.0: the entire error system needs an overhaul - it's not very
|
2010-09-06 19:06:56 +00:00
|
|
|
* useful the way it is. Also, we need to be able to specify additional
|
|
|
|
* 'details' for errors (e.g. disk/file/resource error -> out-of-space; or
|
|
|
|
* put the url/filename/device name that caused the error somewhere)
|
|
|
|
* without having to add enums for every little thing.
|
|
|
|
*
|
2014-09-25 19:21:09 +00:00
|
|
|
* FIXME 2.0: get rid of GST_{CORE,LIBRARY,RESOURCE,STREAM}_ERROR_NUM_ERRORS.
|
2010-09-06 19:06:56 +00:00
|
|
|
* Maybe also replace _quark() functions with g_quark_from_static_string()?
|
|
|
|
*/
|
2004-01-18 21:36:20 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gst_private.h"
|
2004-05-07 02:36:28 +00:00
|
|
|
#include <gst/gst.h>
|
2004-01-18 21:36:20 +00:00
|
|
|
#include "gst-i18n-lib.h"
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define QUARK_FUNC(string) \
|
|
|
|
GQuark gst_ ## string ## _error_quark (void) { \
|
|
|
|
static GQuark quark; \
|
|
|
|
if (!quark) \
|
2004-01-18 21:36:20 +00:00
|
|
|
quark = g_quark_from_static_string ("gst-" # string "-error-quark"); \
|
|
|
|
return quark; }
|
|
|
|
|
2006-06-06 08:50:25 +00:00
|
|
|
#define FILE_A_BUG " Please file a bug at " PACKAGE_BUGREPORT "."
|
2005-11-14 12:17:46 +00:00
|
|
|
|
2010-09-06 19:06:56 +00:00
|
|
|
static const gchar *
|
|
|
|
gst_error_get_core_error (GstCoreError code)
|
2004-01-18 21:36:20 +00:00
|
|
|
{
|
2010-09-06 19:06:56 +00:00
|
|
|
switch (code) {
|
|
|
|
case GST_CORE_ERROR_FAILED:
|
|
|
|
return _("GStreamer encountered a general core library error.");
|
|
|
|
case GST_CORE_ERROR_TOO_LAZY:
|
|
|
|
return _("GStreamer developers were too lazy to assign an error code "
|
|
|
|
"to this error." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_NOT_IMPLEMENTED:
|
|
|
|
return _("Internal GStreamer error: code not implemented." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_STATE_CHANGE:
|
|
|
|
return _("GStreamer error: state change failed and some element failed "
|
|
|
|
"to post a proper error message with the reason for the failure.");
|
|
|
|
case GST_CORE_ERROR_PAD:
|
|
|
|
return _("Internal GStreamer error: pad problem." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_THREAD:
|
|
|
|
return _("Internal GStreamer error: thread problem." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_NEGOTIATION:
|
2012-09-12 20:20:46 +00:00
|
|
|
return _("GStreamer error: negotiation problem.");
|
2010-09-06 19:06:56 +00:00
|
|
|
case GST_CORE_ERROR_EVENT:
|
|
|
|
return _("Internal GStreamer error: event problem." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_SEEK:
|
|
|
|
return _("Internal GStreamer error: seek problem." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_CAPS:
|
|
|
|
return _("Internal GStreamer error: caps problem." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_TAG:
|
|
|
|
return _("Internal GStreamer error: tag problem." FILE_A_BUG);
|
|
|
|
case GST_CORE_ERROR_MISSING_PLUGIN:
|
|
|
|
return _("Your GStreamer installation is missing a plug-in.");
|
|
|
|
case GST_CORE_ERROR_CLOCK:
|
2012-09-12 20:20:46 +00:00
|
|
|
return _("GStreamer error: clock problem.");
|
2010-09-06 19:06:56 +00:00
|
|
|
case GST_CORE_ERROR_DISABLED:
|
|
|
|
return _("This application is trying to use GStreamer functionality "
|
|
|
|
"that has been disabled.");
|
|
|
|
case GST_CORE_ERROR_NUM_ERRORS:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
2004-01-18 21:36:20 +00:00
|
|
|
}
|
|
|
|
|
2010-09-06 19:06:56 +00:00
|
|
|
static const gchar *
|
|
|
|
gst_error_get_library_error (GstLibraryError code)
|
2004-01-18 21:36:20 +00:00
|
|
|
{
|
2010-09-06 19:06:56 +00:00
|
|
|
switch (code) {
|
|
|
|
case GST_LIBRARY_ERROR_FAILED:
|
|
|
|
return _("GStreamer encountered a general supporting library error.");
|
|
|
|
case GST_LIBRARY_ERROR_TOO_LAZY:
|
|
|
|
return _("GStreamer developers were too lazy to assign an error code "
|
|
|
|
"to this error." FILE_A_BUG);
|
|
|
|
case GST_LIBRARY_ERROR_INIT:
|
|
|
|
return _("Could not initialize supporting library.");
|
|
|
|
case GST_LIBRARY_ERROR_SHUTDOWN:
|
|
|
|
return _("Could not close supporting library.");
|
|
|
|
case GST_LIBRARY_ERROR_SETTINGS:
|
|
|
|
return _("Could not configure supporting library.");
|
|
|
|
case GST_LIBRARY_ERROR_ENCODE:
|
2010-09-06 19:16:14 +00:00
|
|
|
return _("Encoding error.");
|
2010-09-06 19:06:56 +00:00
|
|
|
case GST_LIBRARY_ERROR_NUM_ERRORS:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
2004-01-18 21:36:20 +00:00
|
|
|
}
|
|
|
|
|
2010-09-06 19:06:56 +00:00
|
|
|
static const gchar *
|
|
|
|
gst_error_get_resource_error (GstResourceError code)
|
2004-01-18 21:36:20 +00:00
|
|
|
{
|
2010-09-06 19:06:56 +00:00
|
|
|
switch (code) {
|
|
|
|
case GST_RESOURCE_ERROR_FAILED:
|
|
|
|
return _("GStreamer encountered a general resource error.");
|
|
|
|
case GST_RESOURCE_ERROR_TOO_LAZY:
|
|
|
|
return _("GStreamer developers were too lazy to assign an error code "
|
|
|
|
"to this error." FILE_A_BUG);
|
|
|
|
case GST_RESOURCE_ERROR_NOT_FOUND:
|
|
|
|
return _("Resource not found.");
|
|
|
|
case GST_RESOURCE_ERROR_BUSY:
|
|
|
|
return _("Resource busy or not available.");
|
|
|
|
case GST_RESOURCE_ERROR_OPEN_READ:
|
|
|
|
return _("Could not open resource for reading.");
|
|
|
|
case GST_RESOURCE_ERROR_OPEN_WRITE:
|
|
|
|
return _("Could not open resource for writing.");
|
|
|
|
case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
|
|
|
|
return _("Could not open resource for reading and writing.");
|
|
|
|
case GST_RESOURCE_ERROR_CLOSE:
|
|
|
|
return _("Could not close resource.");
|
|
|
|
case GST_RESOURCE_ERROR_READ:
|
|
|
|
return _("Could not read from resource.");
|
|
|
|
case GST_RESOURCE_ERROR_WRITE:
|
|
|
|
return _("Could not write to resource.");
|
|
|
|
case GST_RESOURCE_ERROR_SEEK:
|
|
|
|
return _("Could not perform seek on resource.");
|
|
|
|
case GST_RESOURCE_ERROR_SYNC:
|
|
|
|
return _("Could not synchronize on resource.");
|
|
|
|
case GST_RESOURCE_ERROR_SETTINGS:
|
|
|
|
return _("Could not get/set settings from/on resource.");
|
|
|
|
case GST_RESOURCE_ERROR_NO_SPACE_LEFT:
|
|
|
|
return _("No space left on the resource.");
|
2014-02-11 12:09:11 +00:00
|
|
|
case GST_RESOURCE_ERROR_NOT_AUTHORIZED:
|
|
|
|
return _("Not authorized to access resource.");
|
2010-09-06 19:06:56 +00:00
|
|
|
case GST_RESOURCE_ERROR_NUM_ERRORS:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
2004-01-18 21:36:20 +00:00
|
|
|
}
|
|
|
|
|
2010-09-06 19:06:56 +00:00
|
|
|
static const gchar *
|
|
|
|
gst_error_get_stream_error (GstStreamError code)
|
2004-01-18 21:36:20 +00:00
|
|
|
{
|
2010-09-06 19:06:56 +00:00
|
|
|
switch (code) {
|
|
|
|
case GST_STREAM_ERROR_FAILED:
|
|
|
|
return _("GStreamer encountered a general stream error.");
|
|
|
|
case GST_STREAM_ERROR_TOO_LAZY:
|
|
|
|
return _("GStreamer developers were too lazy to assign an error code "
|
|
|
|
"to this error." FILE_A_BUG);
|
|
|
|
case GST_STREAM_ERROR_NOT_IMPLEMENTED:
|
|
|
|
return _("Element doesn't implement handling of this stream. "
|
|
|
|
"Please file a bug.");
|
|
|
|
case GST_STREAM_ERROR_TYPE_NOT_FOUND:
|
|
|
|
return _("Could not determine type of stream.");
|
|
|
|
case GST_STREAM_ERROR_WRONG_TYPE:
|
|
|
|
return _("The stream is of a different type than handled by this "
|
|
|
|
"element.");
|
|
|
|
case GST_STREAM_ERROR_CODEC_NOT_FOUND:
|
|
|
|
return _("There is no codec present that can handle the stream's type.");
|
|
|
|
case GST_STREAM_ERROR_DECODE:
|
|
|
|
return _("Could not decode stream.");
|
|
|
|
case GST_STREAM_ERROR_ENCODE:
|
|
|
|
return _("Could not encode stream.");
|
|
|
|
case GST_STREAM_ERROR_DEMUX:
|
|
|
|
return _("Could not demultiplex stream.");
|
|
|
|
case GST_STREAM_ERROR_MUX:
|
|
|
|
return _("Could not multiplex stream.");
|
|
|
|
case GST_STREAM_ERROR_FORMAT:
|
|
|
|
return _("The stream is in the wrong format.");
|
|
|
|
case GST_STREAM_ERROR_DECRYPT:
|
|
|
|
return _("The stream is encrypted and decryption is not supported.");
|
|
|
|
case GST_STREAM_ERROR_DECRYPT_NOKEY:
|
|
|
|
return _("The stream is encrypted and can't be decrypted because no "
|
|
|
|
"suitable key has been supplied.");
|
|
|
|
case GST_STREAM_ERROR_NUM_ERRORS:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-01-18 21:36:20 +00:00
|
|
|
|
2010-09-06 19:06:56 +00:00
|
|
|
return NULL;
|
2004-01-18 21:36:20 +00:00
|
|
|
}
|
|
|
|
|
2005-10-23 09:08:44 +00:00
|
|
|
QUARK_FUNC (core);
|
|
|
|
QUARK_FUNC (library);
|
|
|
|
QUARK_FUNC (resource);
|
|
|
|
QUARK_FUNC (stream);
|
2004-01-18 21:36:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_error_get_message:
|
|
|
|
* @domain: the GStreamer error domain this error belongs to.
|
|
|
|
* @code: the error code belonging to the domain.
|
|
|
|
*
|
2005-10-20 21:08:47 +00:00
|
|
|
* Get a string describing the error message in the current locale.
|
|
|
|
*
|
2010-12-07 18:46:01 +00:00
|
|
|
* Returns: (transfer full): a newly allocated string describing
|
|
|
|
* the error message (in UTF-8 encoding)
|
2004-01-18 21:36:20 +00:00
|
|
|
*/
|
2005-10-23 09:08:44 +00:00
|
|
|
gchar *
|
|
|
|
gst_error_get_message (GQuark domain, gint code)
|
2004-01-18 21:36:20 +00:00
|
|
|
{
|
2010-09-06 19:06:56 +00:00
|
|
|
const gchar *message = NULL;
|
2004-01-18 21:36:20 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (domain == GST_CORE_ERROR)
|
2011-08-09 21:33:43 +00:00
|
|
|
message = gst_error_get_core_error ((GstCoreError) code);
|
2004-03-13 15:27:01 +00:00
|
|
|
else if (domain == GST_LIBRARY_ERROR)
|
2011-08-09 21:33:43 +00:00
|
|
|
message = gst_error_get_library_error ((GstLibraryError) code);
|
2004-03-13 15:27:01 +00:00
|
|
|
else if (domain == GST_RESOURCE_ERROR)
|
2011-08-09 21:33:43 +00:00
|
|
|
message = gst_error_get_resource_error ((GstResourceError) code);
|
2004-03-13 15:27:01 +00:00
|
|
|
else if (domain == GST_STREAM_ERROR)
|
2011-08-09 21:33:43 +00:00
|
|
|
message = gst_error_get_stream_error ((GstStreamError) code);
|
2004-03-13 15:27:01 +00:00
|
|
|
else {
|
2004-01-18 21:36:20 +00:00
|
|
|
g_warning ("No error messages for domain %s", g_quark_to_string (domain));
|
2004-03-13 15:27:01 +00:00
|
|
|
return g_strdup_printf (_("No error message for domain %s."),
|
2004-03-15 19:27:17 +00:00
|
|
|
g_quark_to_string (domain));
|
2004-01-18 21:36:20 +00:00
|
|
|
}
|
|
|
|
if (message)
|
2010-09-06 19:06:56 +00:00
|
|
|
return g_strdup (message);
|
2004-01-18 21:36:20 +00:00
|
|
|
else
|
2004-03-13 15:27:01 +00:00
|
|
|
return
|
2004-03-15 19:27:17 +00:00
|
|
|
g_strdup_printf (_
|
|
|
|
("No standard error message for domain %s and code %d."),
|
|
|
|
g_quark_to_string (domain), code);
|
2004-01-18 21:36:20 +00:00
|
|
|
}
|