I have a code snippet which is throwing error when using printStackTrace()
under catch
block of my code. Following is the code snippet.
try
{
# Debug Code added on 19 Feb 2016
logger.log(Level.INFO, "baseDNs[i] = "+baseDNs[i]);
logger.log(Level.INFO, "search ="+search);
logger.log(Level.INFO, "attributes = "+attributes);
it = basicCmAgent.find_managed_objects(baseDNs[i], search, attributes);
}
catch(Exception e)
{
# Debug Code added on 19 Feb 2016
logger.log(Level.SEVERE, "Caught Error : "+e.printStackTrace());
logger.log(Level.WARNING, "Could not find managed objects with base DN " + baseDNs[i]);
return false;
}
Following are the errors:
asses/xml-apis.jar:../3pp_libraries/cxa_classes/irp3gppR99_330_j140.jar -d lib com/ericsson/nms/temip/importer/BasicCmConnection.java
com/ericsson/nms/temip/importer/BasicCmConnection.java:177: 'void' type not allowed here
logger.log(Level.SEVERE, "Caught Error : " +e.printStackTrace());
^
Note: ./com/ericsson/nms/temip/importer/BasicCmConverter.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
*** Error exit code 1
Stop.
*** Error exit code 1
Stop.
How can i fix this?
printStackTrace()
has a void return type, so you can't concatenate it to aString
or use it as an argument for another method.You might want to use
getStackTrace()
instead.