- add debug message for workflow related exceptions
This commit is contained in:
parent
5eaa185cc3
commit
bc5972eea6
|
@ -22,6 +22,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
|
|
||||||
|
@ -386,11 +387,19 @@ public class ModelValidationEngine
|
||||||
{
|
{
|
||||||
String error = validator.modelChange(po, changeType);
|
String error = validator.modelChange(po, changeType);
|
||||||
if (error != null && error.length() > 0)
|
if (error != null && error.length() > 0)
|
||||||
|
{
|
||||||
|
if (log.isLoggable(Level.FINE))
|
||||||
|
{
|
||||||
|
log.log(Level.FINE, "po="+po+" validator="+validator+" changeType="+changeType);
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
//log the exception
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||||
String error = e.getLocalizedMessage();
|
String error = e.getLocalizedMessage();
|
||||||
if (error == null)
|
if (error == null)
|
||||||
error = e.toString();
|
error = e.toString();
|
||||||
|
@ -533,13 +542,20 @@ public class ModelValidationEngine
|
||||||
{
|
{
|
||||||
String error = validator.docValidate(po, docTiming);
|
String error = validator.docValidate(po, docTiming);
|
||||||
if (error != null && error.length() > 0)
|
if (error != null && error.length() > 0)
|
||||||
|
{
|
||||||
|
if (log.isLoggable(Level.FINE))
|
||||||
|
{
|
||||||
|
log.log(Level.FINE, "po="+po+" validator="+validator+" timing="+docTiming);
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
//log the stack trace
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||||
// Exeptions are errors and should stop the document processing - teo_sarca [ 1679692 ]
|
// Exeptions are errors and should stop the document processing - teo_sarca [ 1679692 ]
|
||||||
// log.log(Level.SEVERE, validator.toString(), e);
|
|
||||||
String error = e.getLocalizedMessage();
|
String error = e.getLocalizedMessage();
|
||||||
if (error == null)
|
if (error == null)
|
||||||
error = e.toString();
|
error = e.toString();
|
||||||
|
@ -666,13 +682,20 @@ public class ModelValidationEngine
|
||||||
{
|
{
|
||||||
String error = validator.factsValidate(schema, facts, po);
|
String error = validator.factsValidate(schema, facts, po);
|
||||||
if (error != null && error.length() > 0)
|
if (error != null && error.length() > 0)
|
||||||
|
{
|
||||||
|
if (log.isLoggable(Level.FINE))
|
||||||
|
{
|
||||||
|
log.log(Level.FINE, "po="+po+" schema="+schema+" validator="+validator);
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
//log the stack trace
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||||
// Exeptions are errors and should stop the document processing - teo_sarca [ 1679692 ]
|
// Exeptions are errors and should stop the document processing - teo_sarca [ 1679692 ]
|
||||||
// log.log(Level.SEVERE, validator.toString(), e);
|
|
||||||
String error = e.getLocalizedMessage();
|
String error = e.getLocalizedMessage();
|
||||||
if (error == null)
|
if (error == null)
|
||||||
error = e.toString();
|
error = e.toString();
|
||||||
|
|
|
@ -542,17 +542,25 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
return;
|
return;
|
||||||
//
|
//
|
||||||
StringBuffer TextMsg = new StringBuffer (obj.toString());
|
StringBuffer TextMsg = new StringBuffer ();
|
||||||
if (obj instanceof Exception)
|
if (obj instanceof Exception)
|
||||||
{
|
{
|
||||||
Exception ex = (Exception)obj;
|
Exception ex = (Exception)obj;
|
||||||
|
if (ex.getMessage() != null && ex.getMessage().trim().length() > 0)
|
||||||
|
{
|
||||||
|
TextMsg.append(ex.toString());
|
||||||
|
}
|
||||||
|
else if (ex instanceof NullPointerException)
|
||||||
|
{
|
||||||
|
TextMsg.append(ex.getClass().getName());
|
||||||
|
}
|
||||||
while (ex != null)
|
while (ex != null)
|
||||||
{
|
{
|
||||||
StackTraceElement[] st = ex.getStackTrace();
|
StackTraceElement[] st = ex.getStackTrace();
|
||||||
for (int i = 0; i < st.length; i++)
|
for (int i = 0; i < st.length; i++)
|
||||||
{
|
{
|
||||||
StackTraceElement ste = st[i];
|
StackTraceElement ste = st[i];
|
||||||
if (i == 0 || ste.getClassName().startsWith("org.compiere"))
|
if (i == 0 || ste.getClassName().startsWith("org.compiere") || ste.getClassName().startsWith("org.adempiere"))
|
||||||
TextMsg.append(" (").append(i).append("): ")
|
TextMsg.append(" (").append(i).append("): ")
|
||||||
.append(ste.toString())
|
.append(ste.toString())
|
||||||
.append("\n");
|
.append("\n");
|
||||||
|
@ -563,6 +571,10 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
ex = null;
|
ex = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TextMsg.append(obj.toString());
|
||||||
|
}
|
||||||
//
|
//
|
||||||
String oldText = getTextMsg();
|
String oldText = getTextMsg();
|
||||||
if (oldText == null || oldText.length() == 0)
|
if (oldText == null || oldText.length() == 0)
|
||||||
|
@ -759,6 +771,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
if (!m_state.isValidAction(StateEngine.ACTION_Start))
|
if (!m_state.isValidAction(StateEngine.ACTION_Start))
|
||||||
{
|
{
|
||||||
setTextMsg("State=" + getWFState() + " - cannot start");
|
setTextMsg("State=" + getWFState() + " - cannot start");
|
||||||
|
addTextMsg(new Exception(""));
|
||||||
setWFState(StateEngine.STATE_Terminated);
|
setWFState(StateEngine.STATE_Terminated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1283,6 +1296,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
{
|
{
|
||||||
newState = StateEngine.STATE_Terminated;
|
newState = StateEngine.STATE_Terminated;
|
||||||
setTextMsg ("User Choice: " + e.toString());
|
setTextMsg ("User Choice: " + e.toString());
|
||||||
|
addTextMsg(e);
|
||||||
log.log(Level.WARNING, "", e);
|
log.log(Level.WARNING, "", e);
|
||||||
}
|
}
|
||||||
// Send Approval Notification
|
// Send Approval Notification
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.compiere.process.StateEngine;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.TimeUtil;
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,6 +111,7 @@ public class MWFProcess extends X_AD_WF_Process
|
||||||
if (getPO() == null)
|
if (getPO() == null)
|
||||||
{
|
{
|
||||||
setTextMsg("No PO with ID=" + pi.getRecord_ID());
|
setTextMsg("No PO with ID=" + pi.getRecord_ID());
|
||||||
|
addTextMsg(new Exception(""));
|
||||||
super.setWFState (WFSTATE_Terminated);
|
super.setWFState (WFSTATE_Terminated);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -310,6 +312,7 @@ public class MWFProcess extends X_AD_WF_Process
|
||||||
if (activities.length == 0)
|
if (activities.length == 0)
|
||||||
{
|
{
|
||||||
setTextMsg("No Active Processed found");
|
setTextMsg("No Active Processed found");
|
||||||
|
addTextMsg(new Exception(""));
|
||||||
closedState = WFSTATE_Terminated;
|
closedState = WFSTATE_Terminated;
|
||||||
}
|
}
|
||||||
if (closedState != null)
|
if (closedState != null)
|
||||||
|
@ -503,6 +506,7 @@ public class MWFProcess extends X_AD_WF_Process
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "AD_WF_Node_ID=" + AD_WF_Node_ID, e);
|
log.log(Level.SEVERE, "AD_WF_Node_ID=" + AD_WF_Node_ID, e);
|
||||||
setTextMsg(e.toString());
|
setTextMsg(e.toString());
|
||||||
|
addTextMsg(e);
|
||||||
setWFState(StateEngine.STATE_Terminated);
|
setWFState(StateEngine.STATE_Terminated);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -549,6 +553,55 @@ public class MWFProcess extends X_AD_WF_Process
|
||||||
super.setTextMsg (oldText + "\n - " + TextMsg);
|
super.setTextMsg (oldText + "\n - " + TextMsg);
|
||||||
} // setTextMsg
|
} // setTextMsg
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add to Text Msg
|
||||||
|
* @param obj some object
|
||||||
|
*/
|
||||||
|
public void addTextMsg (Object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
return;
|
||||||
|
//
|
||||||
|
StringBuffer TextMsg = new StringBuffer ();
|
||||||
|
if (obj instanceof Exception)
|
||||||
|
{
|
||||||
|
Exception ex = (Exception)obj;
|
||||||
|
if (ex.getMessage() != null && ex.getMessage().trim().length() > 0)
|
||||||
|
{
|
||||||
|
TextMsg.append(ex.toString());
|
||||||
|
}
|
||||||
|
else if (ex instanceof NullPointerException)
|
||||||
|
{
|
||||||
|
TextMsg.append(ex.getClass().getName());
|
||||||
|
}
|
||||||
|
while (ex != null)
|
||||||
|
{
|
||||||
|
StackTraceElement[] st = ex.getStackTrace();
|
||||||
|
for (int i = 0; i < st.length; i++)
|
||||||
|
{
|
||||||
|
StackTraceElement ste = st[i];
|
||||||
|
if (i == 0 || ste.getClassName().startsWith("org.compiere") || ste.getClassName().startsWith("org.adempiere"))
|
||||||
|
TextMsg.append(" (").append(i).append("): ")
|
||||||
|
.append(ste.toString())
|
||||||
|
.append("\n");
|
||||||
|
}
|
||||||
|
if (ex.getCause() instanceof Exception)
|
||||||
|
ex = (Exception)ex.getCause();
|
||||||
|
else
|
||||||
|
ex = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TextMsg.append(obj.toString());
|
||||||
|
}
|
||||||
|
//
|
||||||
|
String oldText = getTextMsg();
|
||||||
|
if (oldText == null || oldText.length() == 0)
|
||||||
|
super.setTextMsg(Util.trimSize(TextMsg.toString(),1000));
|
||||||
|
else if (TextMsg != null && TextMsg.length() > 0)
|
||||||
|
super.setTextMsg(Util.trimSize(oldText + "\n - " + TextMsg.toString(),1000));
|
||||||
|
} // addTextMsg
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Runtime (Error) Message
|
* Set Runtime (Error) Message
|
||||||
|
|
Loading…
Reference in New Issue