Could someone please provide some good practice to handle exceptions in exception for example I have
try {
...
DeserializationResult deserialization = xmlSerializationService.deserializeFromXml(node);
some code here
} catch (Exception e) {
try {
//I need to create process result xml with error code and some details
// creation of result xml document
} catch (Exception e) {
// maybe some error message here
}
}
can I somehow make this code looks clearer, noiseless and easier to understand?
Thanks for answers. P.S. I know that using general exception is not good practice, its just for example purpose here.
The first approximation for solving that problem is usually to put the logic of the catch in a separate method, and only have one line in the catch block (the method call).