pyslha.py

changeset 166
97ed233d12f8
parent 164
fa5d5692a68b
child 168
9736876969a4
     1.1 --- a/pyslha.py	Sat Mar 03 01:15:12 2012 +0100
     1.2 +++ b/pyslha.py	Sat Mar 03 20:32:13 2012 +0100
     1.3 @@ -24,7 +24,7 @@
     1.4  """
     1.5  
     1.6  __author__ = "Andy Buckley <andy.buckley@cern.ch"
     1.7 -__version__ = "1.3.1"
     1.8 +__version__ = "1.3.2"
     1.9  
    1.10  
    1.11  def _autotype(var):
    1.12 @@ -46,6 +46,14 @@
    1.13      return str(var)
    1.14  
    1.15  
    1.16 +class ParseError(Exception):
    1.17 +    "Exception object to be raised when a spectrum file/string is malformed"
    1.18 +    def __init__(self, errmsg):
    1.19 +        self.msg = errmsg
    1.20 +    def __repr__(self):
    1.21 +        return self.msg
    1.22 +
    1.23 +
    1.24  
    1.25  class Block(object):
    1.26      """
    1.27 @@ -233,7 +241,7 @@
    1.28              if decays.has_key(pid):
    1.29                  decays[pid].mass = blocks["MASS"].entries[pid]
    1.30      except:
    1.31 -        raise Exception("No MASS block found, from which to populate particle masses")
    1.32 +        raise ParseError("No MASS block found: cannot populate particle masses")
    1.33  
    1.34      return blocks, decays
    1.35  

mercurial