Exceptions in K2 Studio


Badge +9

Hi All,


In Process/Activity/Event properties, there is an option called Exception?


What is the use of that ? I mean where exactly can we make use of it ?


Pls reply ASAP.


It's very urgent.


Thanks and Regards.


12 replies

Badge +9

Hi blake,


Thanks a lot for replying.

Badge +9

Hi All,


Please help:


I implemented an IPC Server Event in a process. But in connection information section of the IPC, I selected "Windows Authentication". This caused an error msg like "4121 Server is not configured for windows authentication : Local" to be displayed in the K2.Service Manager.


My doubts are:


1>What is 4121 ?


2>Where actually the error is logged ?


3>I also tried to implement exception concept at the process level to catch the error displayed in Service Manager. The code snippet in exception block at process level is:


public void Main (ExceptionContext K2)
{
 SourceCode.KO.ProcessInstance MyKOProcessInstance;
 MyKOProcessInstance = K2.ProcessInstance;
 object MyErrObject;
 MyErrObject = K2.ExceptionObject;
 
 switch (K2.ContextType)
 {
  case (ContextType.ClientEvent):
   K2.AddToErrorLog = true;
   break;
  
  case (ContextType.DestinationRule):
   K2.AddToErrorLog = true;
   break;
  
  case (ContextType.EscalationAction):
   K2.AddToErrorLog = true;
   break;
  
  case (ContextType.EscalationRule):
   K2.AddToErrorLog = true;
   break;
  
  case (ContextType.IPCEvent):
   K2.AddToErrorLog = false;
   System.Web.Mail.SmtpMail MyMail;
   System.Web.Mail.MailMessage MyMailMessage = new System.Web.Mail.MailMessage();
   object MyMessage;
   string MyErrorMessage;
   System.DateTime MyDate;
   MyMailMessage.From = MyKOProcessInstance.DataFields["MyMail"].Value.ToString();
   MyMailMessage.To = MyKOProcessInstance.DataFields["MyMail"].Value.ToString();
   MyMailMessage.Subject = "IPC Server event exception by the K2.net Server.";
   MyMailMessage.Body = MyErrObject.ToString();
   MyMailMessage.BodyFormat = 0;
   System.Web.Mail.SmtpMail.Send(MyMailMessage);
   break;
  
  case (ContextType.LineRule):
   K2.AddToErrorLog = true;
   break;
  
  case (ContextType.PrecedingRule):
   K2.AddToErrorLog = true;
   break;
  
  case (ContextType.ServerEvent):
   K2.AddToErrorLog = true; 
      break;
    
  case (ContextType.StartRule):
   K2.AddToErrorLog = true;
   break;
  
  case (ContextType.SucceedingRule):
   K2.AddToErrorLog = true;
   break;
 }
}


But I am not getting as to even if K2.AddToErrorLog = false; in the block "case (ContextType.IPCEvent)", then why is the error getting logged.  As per my knowledge ,setting K2.AddToErrorLog to false should not log the error.


The following is the code in the IPC Server Event: 


public void Main(ref IPCEventContext K2)
{


 // Set The Server and Connection String
 K2.Server = "local";
 object iPort;
 iPort = "5252";
 K2.Port = int.Parse(iPort.ToString());
 K2.ConnectionString = "[;];Authentication=Windows;SecurityPackage=";
 if((K2.ConnectionString ==null)||(K2.ConnectionString.ToString().Trim().Length == 0) || Convert.ToBoolean(string.Compare(K2.ConnectionString.Substring(0,19),"W")))
 {
  throw new System.Exception("Server is not configured for windows authentication");
 }


 // Set The Process
 K2.Process = "K2R&DCallingProcessForIPCTestForGroup";
 K2.Synchronous = true;


 // Set The DataField Mappings


 


 


Please reply ASAP.


Thanks and Regards.




 

Badge +3

1>What is 4121 ?


this is a K2 specific error code. a complete list of error codes can be found in: [root]K2.net 2003BinLogger.config


2>Where actually the error is logged ?


Errors are logged in the _ErrorLog table in the K2 database


3>K2.AddToErrorLog = false;


You could try to remove all case statements and turn of the AddToErrorLog for all exceptions to be thrown. have a look at the result and then cradually add the items.


hth


willem

Badge +9

Hi willem,


Thanks a lot for replying.


I have further doubts:


As per my knowledge making K2.AddToErrorLog = false will not cause any error to be logged. But for ContextType.IPCEvent even if I set K2.AddToErrorLog = false still then the following error is logged "4121 Server is not configured for windows authentication : Local". I am confused as to why this is happening?


Also, I think there is no such thing as ContextType.IPCSend.


Please correct me if I am wrong. Pls refer the code snippet in my previous post.


Pls reply ASAP.


Thanks and Regards.


But I am not getting as to even if K2.AddToErrorLog = false; in the block "case (ContextType.IPCEvent)", then why is the error getting logged.  As per my knowledge ,setting K2.AddToErrorLog to false should not log the error.

Badge +9

Hi All,


Consider this :


Scenario 1 


In Process Level Exception Handling, for the case ContextType.IPCEvent, I have set  K2.AddToErrorLog = false and
   K2.AddToServerLog=false.


And I am using a IPCServer Event in my process where I am deleberately via code giving a null connection string i.e.,  K2.ConnectionString = "";


The code snippet is :


public void Main(ref IPCEventContext K2)


 Set The Server and Connection String
 K2.Server = "local";
 object iPort;
 iPort = "5252";
 K2.Port = int.Parse(iPort.ToString());
 K2.ConnectionString = "";
 
K2.Process = "K2R&DCallingProcess";
 K2.Synchronous = true;
}


So I think the error thrown by IPCServer Event should not be logged in the database. But I am able to view the following error message in Service Manager :"4121 Server is not configured for windows authentication : Local". and for the error message, Source is :"IPCSend".


Scenario 2


In Process Level Exception Handling, for the case ContextType.IPCEvent, I have set  K2.AddToErrorLog = false and
   K2.AddToServerLog=false.


And I am using a IPCServer Event in my process where I am deleberately via code giving a null connection string i.e.,  K2.ConnectionString = "";


The following is the code snippet in IPCServer Event :


public void Main(ref IPCEventContext K2)


 Set The Server and Connection String
 K2.Server = "local";
 object iPort;
 iPort = "5252";
 K2.Port = int.Parse(iPort.ToString());
 K2.ConnectionString = "";
 if((K2.ConnectionString ==null)||(K2.ConnectionString.ToString().Trim().Length == 0))
 {
  throw new System.Exception("Server is not configured for windows authentication");
 }


K2.Process = "K2R&DCallingProcess";
 K2.Synchronous = true;
}


So I think the error thrown by IPCServer Event should not be logged in the database. But I am able to view the following error message in Service Manager :"System.Exception: Server is not configured for windows authentication
   at K2Code36124.Main(IPCEventContext& K2
". and for the error message, Source is :"IPCEvent".


Cosidering the above 2 scenarios, the common thing is setting both K2.AddToErrorLog = false and
   K2.AddToServerLog=false in processlevel exceptions and giving a null connection string in IPCServerEvent Code.


But the error is being logged in both cases and source of error is different.


Pls explain.


Pls reply ASAP.


Thanks and Regards.

Badge +3

Hi there.


I think the your authentication between processes fail. Check your authentication when you step through the IPC event wizard, one of the screens requires authentication to start the IPC process. The user K2 uses to start the ipc process does not have start permission. you have to set permissions on the ipc process, it does not inherit permissions from the current process.


 


hth

Badge +9

Hi Wellem,


Thanks a lot for replying.


I have deliberately given a blank connection string to see the source of error. What I get is that the error source is "IPCSend".


But K2 has an option to capture errors related to IPCEvent. I am not getting as to why error logging related to IPCEvent is provided and not IPCSend . What is the exact way to capture error related to "IPCSend" ?


Please reply ASAP.


Thanks and Regards.

Badge +9
Hi blake,
Badge +9

Hi blake,


Thanks a lot for replying.


Actually In Service Manager, the source of the error is being displayed as "IPCSend". That is why I am confused. If the error source is "IPCSend", then  why the associated K2 context object type is "IPCEvent".  And why there is not an "IPCSend" context object type.


Please reply ASAP.


Badge +9

Hi All,


I have attached a screenshot of the Service Manager where the source of error is showing as "IPCSend".


One more request :


Please download the file and view it. I think it will not be visible clearly in the post.


Please reply ASAP.


Thanks and Regards


14704i6E5C55BBF61B2B74.jpg
Badge +9
Hi b
Badge +9

Hi blake,


Thanks a lot for replying.


 As U said, I tried with ContextType.IPCEvent but K2 is unable to trap the error.


The error source being displayed in Service Manager is "IPCSend" . Never it is being displayed as IPCEvent.


I think there is some relation between Source column and ContextType.


By the way, Error Profile also has a column called Type. What does it refer to ?


Thanks and Regards.

Reply