source: SHX/trunk/SeismicHandler/basics/error.py @ 531

Revision 531, 1.7 KB checked in by marcus, 11 years ago (diff)
  • ...
  • method for expanding trace lists
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Rev Id Date
Line 
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2008-2011 Marcus Walther (walther@szgrf.bgr.de)
4#
5# This file is part of Seismic Handler eXtended (SHX)
6# Full details can be found at project website http://www.seismic-handler.org/
7#
8# SHX is free software; you can redistribute it and/or modify
9# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
10# the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12#
13# SHX 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
16# GNU Lesser General Public License for more details.
17#
18# You should have received a copy of the GNU Lesser General Public License
19# along with SHX (see license.txt); if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
21
22"""module for SHX exceptions"""
23
24from SeismicHandler.basics.messages import MessageSystem as msgs, setStatus
25
26__all__ = ['ShxError']
27
28
29class Error(Exception):
30    """
31    Base exception class.
32    """
33
34    def __init__(self):
35        # log message
36        msgs.sendMessage("log.error", message=str(self))
37        setStatus(getattr(self, "status", "unset"))
38
39    def __str__(self):
40        return self.value
41
42
43class ShxError(Error):
44    """
45    Standard error used in SHX. By inheritance all errors will be sent to
46    logfile via message system.
47    """
48
49    def __init__(self, value, status=1):
50        self.value = value
51        self.status = status
52        Error.__init__(self)
53
54
55if __name__ == "__main__":
56    try:
57        raise ShxError("test")
58    except:
59        pass
Note: See TracBrowser for help on using the repository browser.