source: rtems-source-builder/source-builder/sb/error.py @ 158ad68

4.11
Last change on this file since 158ad68 was 158ad68, checked in by Chris Johns <chrisj@…>, on 10/03/20 at 11:53:04

sb: Back port the RTEMS 5 and 6 RSB engine.

  • Build GDb first as we do for RTEMS 5 and later
  • Update GDB to 9.1 for all archs expect SPARC. The SIS patches only apply to 7.9. Disable Python for SPARC

Closes #4111

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20from __future__ import print_function
21
22#
23# Various errors we can raise.
24#
25
26class error(Exception):
27    """Base class for Builder exceptions."""
28    def set_output(self, msg):
29        self.msg = msg
30    def __str__(self):
31        return self.msg
32
33class general(error):
34    """Raise for a general error."""
35    def __init__(self, what):
36        self.set_output('error: ' + str(what))
37
38class internal(error):
39    """Raise for an internal error."""
40    def __init__(self, what):
41        self.set_output('internal error: ' + str(what))
42
43class exit(error):
44    """Raise for to exit."""
45    def __init__(self):
46        pass
47
48if __name__ == '__main__':
49    try:
50        raise general('a general error')
51    except general as gerr:
52        print('caught:', gerr)
53    try:
54        raise internal('an internal error')
55    except internal as ierr:
56        print('caught:', ierr)
Note: See TracBrowser for help on using the repository browser.