if (ex instanceof DicomServiceException) {
dse = (DicomServiceException) ex;
} else {
dse = new DicomServiceException(Status.ProcessingFailure, ex);
}
cmd = dse.mkRSP(dimse.commandFieldOfRSP(), msgId);
data = dse.getDataset();
} else {
DicomMessage out = exchange.getOut(DicomMessage.class);
cmd = out.getCommand();
data = out.getBody(Attributes.class);