Package command_system :: Module errors
[hide private]
[frames] | no frames]

Source Code for Module command_system.errors

 1  # Copyright (C) 2009-2010  Alexander Cherniuk <ts33kr@gmail.com> 
 2  # 
 3  # This program is free software: you can redistribute it and/or modify 
 4  # it under the terms of the GNU General Public License as published by 
 5  # the Free Software Foundation, either version 3 of the License, or 
 6  # (at your option) any later version. 
 7  # 
 8  # This program is distributed in the hope that it will be useful, 
 9  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
11  # GNU General Public License for more details. 
12  # 
13  # You should have received a copy of the GNU General Public License 
14  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
15   
16 -class BaseError(Exception):
17 """ 18 Common base for errors which relate to a specific command. 19 Encapsulates everything needed to identify a command, by either its 20 object or name. 21 """ 22
23 - def __init__(self, message, command=None, name=None):
24 self.message = message 25 26 self.command = command 27 self.name = name 28 29 if command and not name: 30 self.name = command.first_name 31 32 super(BaseError, self).__init__()
33
34 - def __str__(self):
35 return self.message
36
37 -class DefinitionError(BaseError):
38 """ 39 Used to indicate errors occured on command definition. 40 """ 41 pass
42
43 -class CommandError(BaseError):
44 """ 45 Used to indicate errors occured during command execution. 46 """ 47 pass
48
49 -class NoCommandError(BaseError):
50 """ 51 Used to indicate an inability to find the specified command. 52 """ 53 pass
54