1 /*
2 * Copyright (C) 2008 - 2012 Vivien Malerba <malerba@gnome-db.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser 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.
8 *
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 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include <glib/gi18n-lib.h>
21 #include "gda-firebird-util.h"
22
23 GdaConnectionEvent *
_gda_firebird_make_error(GdaConnection * cnc,const gint statement_type)24 _gda_firebird_make_error (GdaConnection *cnc, const gint statement_type)
25 {
26 FirebirdConnectionData *cdata;
27 GdaConnectionEvent *error_ev;
28
29 g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
30
31 cdata = (FirebirdConnectionData*) gda_connection_internal_get_provider_data (cnc);
32 if (!cdata)
33 return NULL;
34
35 error_ev = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
36 gda_connection_event_set_code (error_ev, isc_sqlcode (cdata->status));
37 ISC_SCHAR *description;
38 const ISC_STATUS *p = cdata->status;
39
40 description = g_new0 (ISC_SCHAR, 512);
41 fb_interpret (description, 511, &p);
42 g_print ("MAKE_ERROR [%s]\n", description);
43 gda_connection_event_set_source (error_ev, "[GDA Firebird]");
44 gda_connection_event_set_description (error_ev, description);
45 gda_connection_add_event (cnc, error_ev);
46 g_free (description);
47
48 return error_ev;
49 }
50