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

Revision 469, 1.6 KB checked in by marcus, 11 years ago (diff)
  • moving message from modules to basics to prevent import loops
  • using obspy Stream().clear method
  • 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
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
38    def __str__(self):
39        return self.value
40
41
42class ShxError(Error):
43    """
44    Standard error used in SHX. By inheritance all errors will be sent to
45    logfile via message system.
46    """
47
48    def __init__(self, value):
49        self.value = value
50        Error.__init__(self)
51
52
53if __name__ == "__main__":
54    try:
55        raise ShxError("test")
56    except:
57        pass
Note: See TracBrowser for help on using the repository browser.