Skip to main content
Hello,

I want to code some exception in an event.

When I click on the "Edit Code" button of Exception, I do not have any K2 context. How can I get this context ?
Good Question...

Can't remember exactly where I got it from, but it should look like this:
Sub Main(ByVal K2 As ExceptionContext)

End Sub


Regards,
Ockert
Ok So I have to add this "main" header ?

Because I do not have this, only a blank page, when I click on "Edit Code" button
Yes, add the procedure definition and have a look at the properties and methods of the passed-in K2 object on intellisense.

Regards,
Ockert
here's some sample code to help you get started. Copy this into the blank Exception code window and start playing...

public void Main (ExceptionContext K2)
{
//do not add to error log yet - execute exception handling code first
K2.AddToErrorLog = false;

// Do something with the exception context, e.g.
Console.WriteLine ("ID" + K2.ProcessInstance.ID) ;
Console.WriteLine ("Error text: " + K2.ExceptionObject.ToString());


//if you cannot recover from the error and you want to put the process into error state, throw an exception
throw new ApplicationException(K2.ExceptionObject.ToString());
}


hope this helps...
Ok, thank you...

Following this, is there any chance in this code to make the current activity to restart?

Reply