try { // do something } catch(Exception exc) { exc.printStackTrace(debugOutputStream); // do something }