private void handleError(int statusCode, String responseErrorMsg) { logger.log(Level.SEVERE, responseErrorMsg); procObj.transactionId = procObj.transactionId; procObj.statusCode = statusCode; procObj.errorMessage = responseErrorMsg; if (procObj.processedResults != null) procObj.processedResults.clear(); }
@Override public void handleResult(ProcessObject procObj) { try { logger.log(Level.INFO, "DSR Status Code: " + procObj.getProfile().getDsrStatusCode()); if (procObj.getProfile().getDsrStatusCode() == ResourceConst.SERVER_ERROR) { // DSR Recognition Failure logger.log(Level.WARNING, "No reponse bytes return. Failed to recognize speech."); String responseMsg = "Failed to recognize speech.[-1]"; handleError(ResourceConst.SERVER_ERROR, responseMsg); } else { // pipeline flow for (IResultsHandler handler : processConfig.getHandlers()) procObj = handler.process(procObj); procObj.statusCode = ResourceConst.SERVER_SUCCESS; } } catch (Exception e) { logger.log(Level.WARNING, "Unable to process request due to ", e); String responseMsg = "DSR C-server Error"; handleError(ResourceConst.SERVER_ERROR, responseMsg); } DSRExecutorResponse er = new DSRExecutorResponse(); er.setStatus(procObj.statusCode); er.setErrorMessage(procObj.errorMessage); er.setProcessObject(procObj); er.setExecutorType(executorType); procObj.profile.totalProcessEnd(); // call back to the framework with the result try { callback.doCallback(null, er); } catch (Exception e) { logger.log(Level.WARNING, "Exception calling back to server", e); } // callback.doEnd(); }