1 /* D-Bus exception base classes.
3 * Copyright (C) 2006 Collabora Ltd.
5 * Licensed under the Academic Free License version 2.1
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "dbus_bindings-internal.h"
27 PyObject
*DBusPyException
;
29 PyDoc_STRVAR(DBusException__doc__
, "Represents any D-Bus-related error.");
32 DBusPyException_ConsumeError(DBusError
*error
)
34 PyErr_Format(DBusPyException
, "%s: %s",
35 error
->name
, error
->message
);
36 dbus_error_free(error
);
41 dbus_py_init_exception_types(void)
44 PyObject
*dict
= PyDict_New();
49 if (PyDict_SetItemString(dict
, "__doc__",
50 PyString_FromString(DBusException__doc__
)) < 0)
52 if (PyDict_SetItemString(dict
, "__module__",
53 PyString_FromString("dbus")) < 0)
55 bases
= Py_BuildValue("(O)", (PyObject
*)PyExc_Exception
);
60 name
= PyString_FromString("DBusException");
66 DBusPyException
= PyClass_New(bases
, dict
, name
);
75 dbus_py_insert_exception_types(PyObject
*this_module
)
77 if (PyModule_AddObject(this_module
, "DBusException", DBusPyException
) < 0) {
83 /* vim:set ft=c cino< sw=4 sts=4 et: */