Changeset 3287 for branches

Show
Ignore:
Timestamp:
01/26/12 21:07:14 (4 months ago)
Author:
erkn
Message:

Only catch known exceptions

Location:
branches/mcxtrace-1.0/src/mcrun2
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • branches/mcxtrace-1.0/src/mcrun2/main.py

    r3286 r3287  
    22 
    33import logging 
     4from log import McRunException 
    45 
    56from os.path import isfile, isdir, abspath, dirname 
     
    321322        main() 
    322323    except KeyboardInterrupt: 
    323         exit(1) 
    324     except Exception, e: 
     324        LOG.fatal('User interrupt.') 
     325    except OptionValueError, e: 
    325326        LOG.fatal(str(e)) 
     327    except McRunException, e: 
     328        LOG.fatal(str(e)) 
  • branches/mcxtrace-1.0/src/mcrun2/optimisation.py

    r3286 r3287  
    11from os import mkdir 
     2 
     3from log import McRunException 
     4 
    25import logging 
    36LOG = logging.getLogger('mcstas.optimisation') 
     
    8790 
    8891 
     92class InvalidInterval(McRunException): 
     93    pass 
     94 
     95 
    8996class Scanner: 
    9097    def __init__(self, mcstas, intervals): 
     
    104111 
    105112        if len(self.intervals) == 0: 
    106             LOG.fatal('No intervals specified! (e.g. lambda=1.0,5.0)') 
    107             exit(1) 
     113            raise InvalidInterval('No interval range specified') 
    108114 
    109115        fid = open(self.outfile, 'w')