1 # -*- Mode: Python; py-indent-offset: 4 -*-
2 # vim: tabstop=4 shiftwidth=4 expandtab
4 # Copyright (C) 2014 Simon Feltman <sfeltman@gnome.org>
6 # _error.py: GError Python implementation
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
24 # NOTE: This file should not have any dependencies on introspection libs
25 # like gi.repository.GLib because it would cause a circular dependency.
26 # Developers wanting to use the GError class in their applications should
27 # use gi.repository.GLib.GError
30 class GError(RuntimeError):
31 def __init__(self
, message
='unknown error', domain
='pygi-error', code
=0):
32 super(GError
, self
).__init
__(message
)
33 self
.message
= message
38 return "%s: %s (%d)" % (self
.domain
, self
.message
, self
.code
)
41 return "%s.%s('%s', '%s', %d)" % (
42 GError
.__module
__.rsplit(".", 1)[-1], GError
.__name
__,
43 self
.message
, self
.domain
, self
.code
)
46 return GError(self
.message
, self
.domain
, self
.code
)
48 def matches(self
, domain
, code
):
49 """Placeholder that will be monkey patched in GLib overrides."""
50 raise NotImplementedError
53 def new_literal(domain
, message
, code
):
54 """Placeholder that will be monkey patched in GLib overrides."""
55 raise NotImplementedError