Returning ``++null++`` when something goes wrong instead of throwing an exception leaves callers with no understanding of what went wrong. Instead, an exception should be thrown.


== Noncompliant Code Example

----
public MyClass readFile(String fileName) {
  MyClass mc;
  try {
    // read object from file
  } catch (IOException e) {
    // do cleanup
    return null;  // Noncompliant; why did this fail?
  }
  return mc;
}
----


== Compliant Solution

----
public MyClass readFile(String fileName) throws IOException{
  MyClass mc;
  try {
    // read object from file
  } catch (IOException e) {
    // do cleanup
    throw e;
  }
  return mc;
}
----

