2 * Copyright (C) <2003> David A. Schleef <ds@schleef.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 * @short_description: Categorized error messages
30 #include "gst_private.h"
32 #include "gst-i18n-lib.h"
34 #define TABLE(t, d, a, b) t[GST_ ## d ## _ERROR_ ## a] = g_strdup (b)
35 #define QUARK_FUNC(string) \
36 GQuark gst_ ## string ## _error_quark (void) { \
37 static GQuark quark; \
39 quark = g_quark_from_static_string ("gst-" # string "-error-quark"); \
43 gst_g_error_get_type (void)
45 static GType type = 0;
48 type = g_boxed_type_register_static ("GstGError",
49 (GBoxedCopyFunc) g_error_copy, (GBoxedFreeFunc) g_error_free);
53 /* initialize the dynamic table of translated core errors */
55 _gst_core_errors_init (void)
59 t = g_new0 (gchar *, GST_CORE_ERROR_NUM_ERRORS);
61 TABLE (t, CORE, FAILED,
62 N_("GStreamer encountered a general core library error."));
63 TABLE (t, CORE, TOO_LAZY,
64 N_("GStreamer developers were too lazy to assign an error code "
65 "to this error. Please file a bug."));
66 TABLE (t, CORE, NOT_IMPLEMENTED,
68 ("Internal GStreamer error: code not implemented. Please file a bug."));
69 TABLE (t, CORE, STATE_CHANGE,
70 N_("Internal GStreamer error: state change failed. Please file a bug."));
72 N_("Internal GStreamer error: pad problem. Please file a bug."));
73 TABLE (t, CORE, THREAD,
74 N_("Internal GStreamer error: thread problem. Please file a bug."));
75 TABLE (t, CORE, NEGOTIATION,
76 N_("Internal GStreamer error: negotiation problem. Please file a bug."));
77 TABLE (t, CORE, EVENT,
78 N_("Internal GStreamer error: event problem. Please file a bug."));
80 N_("Internal GStreamer error: seek problem. Please file a bug."));
82 N_("Internal GStreamer error: caps problem. Please file a bug."));
84 N_("Internal GStreamer error: tag problem. Please file a bug."));
89 /* initialize the dynamic table of translated library errors */
91 _gst_library_errors_init (void)
95 t = g_new0 (gchar *, GST_LIBRARY_ERROR_NUM_ERRORS);
97 TABLE (t, LIBRARY, FAILED,
98 N_("GStreamer encountered a general supporting library error."));
99 TABLE (t, LIBRARY, TOO_LAZY,
100 N_("GStreamer developers were too lazy to assign an error code "
101 "to this error. Please file a bug."));
102 TABLE (t, LIBRARY, INIT, N_("Could not initialize supporting library."));
103 TABLE (t, LIBRARY, SHUTDOWN, N_("Could not close supporting library."));
104 TABLE (t, LIBRARY, SETTINGS, N_("Could not close supporting library."));
109 /* initialize the dynamic table of translated resource errors */
111 _gst_resource_errors_init (void)
115 t = g_new0 (gchar *, GST_RESOURCE_ERROR_NUM_ERRORS);
117 TABLE (t, RESOURCE, FAILED,
118 N_("GStreamer encountered a general resource error."));
119 TABLE (t, RESOURCE, TOO_LAZY,
120 N_("GStreamer developers were too lazy to assign an error code "
121 "to this error. Please file a bug."));
122 TABLE (t, RESOURCE, NOT_FOUND, N_("Resource not found."));
123 TABLE (t, RESOURCE, BUSY, N_("Resource busy or not available."));
124 TABLE (t, RESOURCE, OPEN_READ, N_("Could not open resource for reading."));
125 TABLE (t, RESOURCE, OPEN_WRITE, N_("Could not open resource for writing."));
126 TABLE (t, RESOURCE, OPEN_READ_WRITE,
127 N_("Could not open resource for reading and writing."));
128 TABLE (t, RESOURCE, CLOSE, N_("Could not close resource."));
129 TABLE (t, RESOURCE, READ, N_("Could not read from resource."));
130 TABLE (t, RESOURCE, WRITE, N_("Could not write to resource."));
131 TABLE (t, RESOURCE, SEEK, N_("Could not perform seek on resource."));
132 TABLE (t, RESOURCE, SYNC, N_("Could not synchronize on resource."));
133 TABLE (t, RESOURCE, SETTINGS,
134 N_("Could not get/set settings from/on resource."));
139 /* initialize the dynamic table of translated stream errors */
141 _gst_stream_errors_init (void)
145 t = g_new0 (gchar *, GST_STREAM_ERROR_NUM_ERRORS);
147 TABLE (t, STREAM, FAILED,
148 N_("GStreamer encountered a general stream error."));
149 TABLE (t, STREAM, TOO_LAZY,
150 N_("GStreamer developers were too lazy to assign an error code "
151 "to this error. Please file a bug."));
152 TABLE (t, STREAM, NOT_IMPLEMENTED,
153 N_("Element doesn't implement handling of this stream. "
154 "Please file a bug."));
155 TABLE (t, STREAM, TYPE_NOT_FOUND, N_("Could not determine type of stream."));
156 TABLE (t, STREAM, WRONG_TYPE,
157 N_("The stream is of a different type than handled by this element."));
158 TABLE (t, STREAM, CODEC_NOT_FOUND,
159 N_("There is no codec present that can handle the stream's type."));
160 TABLE (t, STREAM, DECODE, N_("Could not decode stream."));
161 TABLE (t, STREAM, ENCODE, N_("Could not encode stream."));
162 TABLE (t, STREAM, DEMUX, N_("Could not demultiplex stream."));
163 TABLE (t, STREAM, MUX, N_("Could not multiplex stream."));
164 TABLE (t, STREAM, FORMAT, N_("Stream is of the wrong format."));
165 TABLE (t, STREAM, STOPPED, N_("Streaming stopped."));
172 QUARK_FUNC (resource)
176 * gst_error_get_message:
177 * @domain: the GStreamer error domain this error belongs to.
178 * @code: the error code belonging to the domain.
180 * Returns: a newly allocated string describing the error message in the
183 gchar *gst_error_get_message (GQuark domain, gint code)
185 static gchar **gst_core_errors = NULL;
186 static gchar **gst_library_errors = NULL;
187 static gchar **gst_resource_errors = NULL;
188 static gchar **gst_stream_errors = NULL;
190 gchar *message = NULL;
192 /* initialize error message tables if necessary */
193 if (gst_core_errors == NULL)
194 gst_core_errors = _gst_core_errors_init ();
195 if (gst_library_errors == NULL)
196 gst_library_errors = _gst_library_errors_init ();
197 if (gst_resource_errors == NULL)
198 gst_resource_errors = _gst_resource_errors_init ();
199 if (gst_stream_errors == NULL)
200 gst_stream_errors = _gst_stream_errors_init ();
203 if (domain == GST_CORE_ERROR)
204 message = gst_core_errors[code];
205 else if (domain == GST_LIBRARY_ERROR)
206 message = gst_library_errors[code];
207 else if (domain == GST_RESOURCE_ERROR)
208 message = gst_resource_errors[code];
209 else if (domain == GST_STREAM_ERROR)
210 message = gst_stream_errors[code];
212 g_warning ("No error messages for domain %s", g_quark_to_string (domain));
213 return g_strdup_printf (_("No error message for domain %s."),
214 g_quark_to_string (domain));
217 return g_strdup (_(message));
221 ("No standard error message for domain %s and code %d."),
222 g_quark_to_string (domain), code);