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.
25 #include "gst_private.h"
26 #include "gst-i18n-lib.h"
28 #define TABLE(t, d, a, b) t[GST_ ## d ## _ERROR_ ## a] = g_strdup (b)
29 #define QUARK_FUNC(string) \
30 GQuark gst_ ## string ## _error_quark (void) { \
31 static GQuark quark; \
33 quark = g_quark_from_static_string ("gst-" # string "-error-quark"); \
37 gst_g_error_get_type (void)
39 static GType type = 0;
42 type = g_boxed_type_register_static ("GstGError",
43 (GBoxedCopyFunc) g_error_copy,
44 (GBoxedFreeFunc) g_error_free);
48 /* initialize the dynamic table of translated core errors */
49 static gchar ** _gst_core_errors_init ()
53 t = g_new0 (gchar *, GST_CORE_ERROR_NUM_ERRORS);
55 TABLE (t, CORE, FAILED,
56 N_("GStreamer encountered a general core library error."));
57 TABLE (t, CORE, TOO_LAZY,
58 N_("GStreamer developers were too lazy to assign an error code "
59 "to this error. Please file a bug."));
60 TABLE (t, CORE, NOT_IMPLEMENTED,
61 N_("Internal GStreamer error: code not implemented. File a bug."));
62 TABLE (t, CORE, STATE_CHANGE,
63 N_("Internal GStreamer error: state change failed. File a bug."));
65 N_("Internal GStreamer error: pad problem. File a bug."));
66 TABLE (t, CORE, THREAD,
67 N_("Internal GStreamer error: thread problem. File a bug."));
68 TABLE (t, CORE, SCHEDULER,
69 N_("Internal GStreamer error: scheduler problem. File a bug."));
70 TABLE (t, CORE, NEGOTIATION,
71 N_("Internal GStreamer error: negotiation problem. File a bug."));
72 TABLE (t, CORE, EVENT,
73 N_("Internal GStreamer error: event problem. File a bug."));
75 N_("Internal GStreamer error: seek problem. File a bug."));
77 N_("Internal GStreamer error: caps problem. File a bug."));
79 N_("Internal GStreamer error: tag problem. File a bug."));
84 /* initialize the dynamic table of translated library errors */
85 static gchar ** _gst_library_errors_init ()
89 t = g_new0 (gchar *, GST_LIBRARY_ERROR_NUM_ERRORS);
91 TABLE (t, LIBRARY, FAILED,
92 N_("GStreamer encountered a general supporting library error."));
93 TABLE (t, LIBRARY, TOO_LAZY,
94 N_("GStreamer developers were too lazy to assign an error code "
95 "to this error. Please file a bug."));
96 TABLE (t, LIBRARY, INIT,
97 N_("Could not initialize supporting library."));
98 TABLE (t, LIBRARY, SHUTDOWN,
99 N_("Could not close supporting library."));
100 TABLE (t, LIBRARY, SETTINGS,
101 N_("Could not close supporting library."));
106 /* initialize the dynamic table of translated resource errors */
107 static gchar ** _gst_resource_errors_init ()
111 t = g_new0 (gchar *, GST_RESOURCE_ERROR_NUM_ERRORS);
113 TABLE (t, RESOURCE, FAILED,
114 N_("GStreamer encountered a general supporting library error."));
115 TABLE (t, RESOURCE, TOO_LAZY,
116 N_("GStreamer developers were too lazy to assign an error code "
117 "to this error. Please file a bug."));
118 TABLE (t, RESOURCE, NOT_FOUND,
119 N_("Resource not found."));
120 TABLE (t, RESOURCE, BUSY,
121 N_("Resource busy or not available."));
122 TABLE (t, RESOURCE, OPEN_READ,
123 N_("Could not open resource for reading."));
124 TABLE (t, RESOURCE, OPEN_WRITE,
125 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,
129 N_("Could not close resource."));
130 TABLE (t, RESOURCE, READ,
131 N_("Could not read from resource."));
132 TABLE (t, RESOURCE, WRITE,
133 N_("Could not write to resource."));
134 TABLE (t, RESOURCE, SEEK,
135 N_("Could not perform seek on resource."));
136 TABLE (t, RESOURCE, SYNC,
137 N_("Could not synchronize on resource."));
138 TABLE (t, RESOURCE, SETTINGS,
139 N_("Could not get/set settings from/on resource."));
144 /* initialize the dynamic table of translated stream errors */
145 static gchar ** _gst_stream_errors_init ()
149 t = g_new0 (gchar *, GST_STREAM_ERROR_NUM_ERRORS);
151 TABLE (t, STREAM, FAILED,
152 N_("GStreamer encountered a general supporting library error."));
153 TABLE (t, STREAM, TOO_LAZY,
154 N_("GStreamer developers were too lazy to assign an error code "
155 "to this error. Please file a bug."));
156 TABLE (t, STREAM, NOT_IMPLEMENTED,
157 N_("Element doesn't implement handling of this stream. "
158 "Please file a bug."));
159 TABLE (t, STREAM, TYPE_NOT_FOUND,
160 N_("Could not determine type of stream."));
161 TABLE (t, STREAM, WRONG_TYPE,
162 N_("The stream is of a different type than handled by this element."));
163 TABLE (t, STREAM, CODEC_NOT_FOUND,
164 N_("There is no codec present that can handle the stream's type."));
165 TABLE (t, STREAM, DECODE,
166 N_("Could not decode stream."));
167 TABLE (t, STREAM, ENCODE,
168 N_("Could not encode stream."));
169 TABLE (t, STREAM, DEMUX,
170 N_("Could not demultiplex stream."));
171 TABLE (t, STREAM, MUX,
172 N_("Could not multiplex stream."));
173 TABLE (t, STREAM, FORMAT,
174 N_("Stream is of the wrong format."));
181 QUARK_FUNC (resource)
185 * gst_error_get_message:
186 * @domain: the GStreamer error domain this error belongs to.
187 * @code: the error code belonging to the domain.
189 * Returns: a newly allocated string describing the error message in the
194 gst_error_get_message (GQuark domain, gint code)
196 static gchar **gst_core_errors = NULL;
197 static gchar **gst_library_errors = NULL;
198 static gchar **gst_resource_errors = NULL;
199 static gchar **gst_stream_errors = NULL;
201 gchar *message = NULL;
203 /* initialize error message tables if necessary */
204 if (gst_core_errors == NULL)
205 gst_core_errors = _gst_core_errors_init ();
206 if (gst_library_errors == NULL)
207 gst_library_errors = _gst_library_errors_init ();
208 if (gst_resource_errors == NULL)
209 gst_resource_errors = _gst_resource_errors_init ();
210 if (gst_stream_errors == NULL)
211 gst_stream_errors = _gst_stream_errors_init ();
214 if (domain == GST_CORE_ERROR) message = gst_core_errors [code];
215 else if (domain == GST_LIBRARY_ERROR) message = gst_library_errors [code];
216 else if (domain == GST_RESOURCE_ERROR) message = gst_resource_errors[code];
217 else if (domain == GST_STREAM_ERROR) message = gst_stream_errors [code];
220 g_warning ("No error messages for domain %s", g_quark_to_string (domain));
221 return g_strdup_printf (_("No error message for domain %s."), g_quark_to_string (domain));
224 return g_strdup (_(message));
226 return g_strdup_printf (_("No standard error message for domain %s and code %d."),
227 g_quark_to_string (domain), code);