*
* @param sfe
* @return
*/
public static ExceptionProtocol createError(ServiceFrameException sfe) {
ExceptionProtocol error = new ExceptionProtocol();
if (sfe != null) {
if (sfe.getState() == null) {
sfe.setState(ErrorState.OtherException);
}
error.setErrorCode(sfe.getState().getStateNum());
StringBuilder sbError = new StringBuilder();
sbError.append("error num:");
sbError.append(System.nanoTime());
sbError.append("--state:");
sbError.append(sfe.getState().toString());
sbError.append("--fromIP:");
if(sfe.getFromIP()!= null) {
sbError.append(sfe.getFromIP());
}
sbError.append("--toIP:");
if(sfe.getToIP()!= null) {
sbError.append(sfe.getToIP());
}
sbError.append("--Message:");
if (sfe.getMessage() != null) {
sbError.append(sfe.getMessage());
}
sbError.append(getStackTrace(sfe));
error.setErrorMsg(sbError.toString());
error.setFromIP(sfe.getFromIP());
error.setToIP(sfe.getToIP());
}
return error;
}