tests: don't test for specific device labels
[pygobject.git] / gi / _error.py
blob6440ef786b37fb4394d4a9c164a3f93106f5d64e
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
21 # USA
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
34 self.domain = domain
35 self.code = code
37 def __str__(self):
38 return "%s: %s (%d)" % (self.domain, self.message, self.code)
40 def __repr__(self):
41 return "%s.%s('%s', '%s', %d)" % (
42 GError.__module__.rsplit(".", 1)[-1], GError.__name__,
43 self.message, self.domain, self.code)
45 def copy(self):
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
52 @staticmethod
53 def new_literal(domain, message, code):
54 """Placeholder that will be monkey patched in GLib overrides."""
55 raise NotImplementedError