source: rtems-tools/specbuilder/specbuilder/error.py @ 7231f49

4.104.115
Last change on this file since 7231f49 was 7231f49, checked in by Chris Johns <chrisj@…>, on 08/09/10 at 01:29:43

2010-08-09 Chris Johns <chrisj@…>

  • specbuilder, specbuilder/sb-build, specbuilder/sb-crossgcc, specbuilder/sb-setup, specbuilder/sb-specdump, specbuilder/sb-status, specbuilder/specbuilder/.cvsignore, specbuilder/specbuilder/build.py, specbuilder/specbuilder/config.sub, specbuilder/specbuilder/crossgcc.py, specbuilder/specbuilder/darwin.py, specbuilder/specbuilder/defaults.py, specbuilder/specbuilder/error.py, specbuilder/specbuilder/execute.py, specbuilder/specbuilder/log.py, specbuilder/specbuilder/setup.py, specbuilder/specbuilder/spec.py, specbuilder/specbuilder/status.py: New.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1#
2# $Id$
3#
4# RTEMS Tools Project (http://www.rtems.org/)
5# Copyright 2010 Chris Johns (chrisj@rtems.org)
6# All rights reserved.
7#
8# This file is part of the RTEMS Tools package in 'rtems-tools'.
9#
10# RTEMS Tools is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# RTEMS Tools is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with RTEMS Tools.  If not, see <http://www.gnu.org/licenses/>.
22#
23
24#
25# Various errors we can raise.
26#
27
28class error(Exception):
29    """Base class for Builder exceptions."""
30    def set_output(self, msg):
31        self.msg = msg
32    def __str__(self):
33        return self.msg
34
35class general(error):
36    """Raise for a general error."""
37    def __init__(self, what):
38        self.set_output('error: ' + what)
39   
40class internal(error):
41    """Raise for an internal error."""
42    def __init__(self, what):
43        self.set_output('internal error: ' + what)
44   
45if __name__ == '__main__':
46    try:
47        raise general('a general error')
48    except general, gerr:
49        print 'caught:', gerr
50    try:
51        raise internal('an internal error')
52    except internal, ierr:
53        print 'caught:', ierr
Note: See TracBrowser for help on using the repository browser.