ER-097 Declare only predefined set of exceptions in throws clause (application layer specific)

Severity2
Enabledno
Waivable
Configuration
Allowed exceptions in the thorws clauses:
allowed-throw: org.hammurapi.inspectors.testcases.HammurapiTestCasesException	
Violation
public void setFirstByte(final String fName)	throws IOException {
	FileInputStream fin = null;
	fin = new FileInputStream(fName);
	firstByte = fin.read();
	fin.close();
}
Fix
public void setFirstByte(final String fName)throws HammurapiTestCasesException {
	FileInputStream fin = null;
	try {
		fin = new FileInputStream(fName);
		firstByte = fin.read();
		fin.close();
	} catch (IOException e) {
		logger.error(FILE_ERROR_TXT, e);
		throw new HammurapiTestCasesException(e);
	}
}


Hammurapi 3 Copyright © 2004 Hammurapi Group. All Rights Reserved.