Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff

import java.io.FileInputStream;
import java.io.FileNotFoundException;

class NewException extends Exception {
  //common exception for abstraction purposes	
  public NewException() {
    super("Error!");
  }
}

class ExceptionExample {
  public static void main(String[] args) throws NewException {
    try {
      FileInputStream dis = new FileInputStream("c:\\" + args[0]);
    }
    catch(FileNotFoundException fnf) { 
      throw new NewException(); 
    } //sanitized message
  }
}

While following this guideline, make sure that security exceptions such as java.security.AccessControlException and java.lang.SecurityException are not swallowed or masked in the process. This can lead to far more pernicious effects.

Risk Assessment

Exceptions may inadvertently reveal sensitive information unless care is taken to limit the information displayed as the result of an exception.

...

Wiki Markup
\[[SCG 07|AA. Java References#SCG 07]\] Guideline 3-4 Purge sensitive information from exceptions
\[[Gong 03|AA. Java References#Gong 03]\] 9.1 Security Exceptions

...

EXC00-J. Handle exceptions appropriately      10. Exceptional Behavior (EXC)      EXC02-J. Prevent exceptions while logging data