[edit] avoid catching unspecified Exceptions
specific Exception catchment is better than general; additionally errors are raised for better debugging control
This commit is contained in:
		
							parent
							
								
									31d56cb287
								
							
						
					
					
						commit
						722e21f582
					
				@ -1,6 +1,7 @@
 | 
			
		||||
#!/usr/bin/env python
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
 | 
			
		||||
from pylot.core.util.errors import ParameterError
 | 
			
		||||
 | 
			
		||||
class AutoPickParameter(object):
 | 
			
		||||
    '''
 | 
			
		||||
@ -57,7 +58,7 @@ class AutoPickParameter(object):
 | 
			
		||||
            for line in lines:
 | 
			
		||||
                parspl = line.split('\t')[:2]
 | 
			
		||||
                parFileCont[parspl[0].strip()] = parspl[1]
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
        except IndexError as e:
 | 
			
		||||
            self._printParameterError(e)
 | 
			
		||||
            inputFile.seek(0)
 | 
			
		||||
            lines = inputFile.readlines()
 | 
			
		||||
@ -136,11 +137,13 @@ class AutoPickParameter(object):
 | 
			
		||||
                    return self.__getitem__(param)
 | 
			
		||||
                except KeyError as e:
 | 
			
		||||
                    self._printParameterError(e)
 | 
			
		||||
                    raise ParameterError(e)
 | 
			
		||||
        except TypeError:
 | 
			
		||||
            try:
 | 
			
		||||
                return self.__getitem__(args)
 | 
			
		||||
            except KeyError as e:
 | 
			
		||||
                self._printParameterError(e)
 | 
			
		||||
                raise ParameterError(e)
 | 
			
		||||
 | 
			
		||||
    def setParam(self, **kwargs):
 | 
			
		||||
        for param, value in kwargs.items():
 | 
			
		||||
 | 
			
		||||
@ -20,3 +20,6 @@ class DatastructureError(Exception):
 | 
			
		||||
 | 
			
		||||
class OverwriteError(IOError):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
class ParameterError(Exception):
 | 
			
		||||
    pass
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user