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