Mercurial > fife-parpg
annotate demos/rpg/scripts/misc/exceptions.py @ 650:51bbda7676f0
* Fixed some more integer definitions
* All vars containing bits per pixel should now be uint16_t
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 14 Oct 2010 15:32:09 +0000 |
parents | 69d50e751c9a |
children |
rev | line source |
---|---|
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # -*- coding: utf-8 -*- |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # #################################################################### |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # Copyright (C) 2005-2010 by the FIFE team |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # http://www.fifengine.net |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # This file is part of FIFE. |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # FIFE is free software; you can redistribute it and/or |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # modify it under the terms of the GNU Lesser General Public |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # License as published by the Free Software Foundation; either |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # version 2.1 of the License, or (at your option) any later version. |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # This library is distributed in the hope that it will be useful, |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # Lesser General Public License for more details. |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # You should have received a copy of the GNU Lesser General Public |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # License along with this library; if not, write to the |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # Free Software Foundation, Inc., |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 # #################################################################### |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
560
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
26 class RPGDemoException(Exception): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
27 def __init__(self, msg=None): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
28 if msg: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
29 self._msg = msg |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
30 else: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
31 self._msg = None |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 |
560
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
33 class InvalidCommandError(RPGDemoException): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
34 def __init__(self, msg=None): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
35 super(InvalidCommandError, self).__init__(msg) |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
36 |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
37 def __str__(self): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
38 if self._msg: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
39 return repr(self._msg) |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
40 else: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
41 return repr("Command not found!") |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
42 |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
43 class ObjectNotFoundError(RPGDemoException): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
44 def __init__(self, msg=None): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
45 super(ObjectNotFoundError, self).__init__(msg) |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 def __str__(self): |
560
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
48 if self._msg: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
49 return repr(self._msg) |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
50 else: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
51 return repr("Object was not found!") |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 |
560
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
53 class ObjectAlreadyInSceneError(RPGDemoException): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
54 def __init__(self, msg=None): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
55 super(ObjectAlreadyInSceneError, self).__init__(msg) |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 def __str__(self): |
560
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
58 if self._msg: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
59 return repr(self._msg) |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
60 else: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
61 return repr("Object was already part of the scene!") |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
62 |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
63 class InstanceNotFoundError(RPGDemoException): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
64 def __init__(self, msg=None): |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
65 super(InstanceNotFoundError, self).__init__(msg) |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
66 |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
67 def __str__(self): |
560
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
68 if self._msg: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
69 return repr(self._msg) |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
70 else: |
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
71 return repr("Instance was not found on layer!") |