The event handler receives an argument of type ExchangeExceptionEventArgs containing data related to this event.
The following
ExchangeExceptionEventArgs properties provide information specific to this event.
Property |
Description |
Handled |
Gets or sets whether an event was handled. If it was handled, the exception is not propagated. |
OriginalException |
Provides access to a .NET exception which originated this event. |
Handle this event to intercept exceptions thrown during export/import processes started by AppointmentExporter.Export or AppointmentImporter.Import methods. When necessary, you can terminate the process by calling the Terminate method.
The following code illustrates handling exceptions that may occur during an import operation performed by the iCalendarImporter.
To handle exceptions, subscribe to the OnException event before calling the AppointmentImporter.Import method. When an exception occurs, the import process is terminated, so no data are loaded into the Scheduler.
If an exception fires while parsing iCal data, a cast of event arguments object to the iCalendarParseExceptionEventArgs type is performed successfully and the information on the iCalendarParseExceptionEventArgs.LineIndex and the iCalendarParseExceptionEventArgs.LineText is displayed. Otherwise System.Exception object is retrieved, to display the exception description.
Form1.cs |
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.iCalendar;
void importer_OnException(object sender, ExchangeExceptionEventArgs e) {
iCalendarParseExceptionEventArgs args = e as iCalendarParseExceptionEventArgs;
if (args != null) {
if (ckhBreakOnError.Checked) {
iCalendarImporter importer = (iCalendarImporter)sender;
importer.Terminate();
}
ShowErrorMessage(String.Format("Cannot parse line {0} with text '{1}'",
args.LineIndex, args.LineText));
}
else
ShowErrorMessage(e.OriginalException.Message);
e.Handled = true;
}
|
Form1.vb |
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.iCalendar
Private Sub importer_OnException(ByVal sender As Object, ByVal e As ExchangeExceptionEventArgs)
Dim args As iCalendarParseExceptionEventArgs = TryCast(e, iCalendarParseExceptionEventArgs)
If args IsNot Nothing Then
If ckhBreakOnError.Checked Then
Dim importer As iCalendarImporter = DirectCast(sender, iCalendarImporter)
importer.Terminate()
End If
ShowErrorMessage(String.Format("Cannot parse line {0} with text '{1}'", args.LineIndex, args.LineText))
Else
ShowErrorMessage(e.OriginalException.Message)
End If
e.Handled = True ' prevent this exception from throwing
End Sub
|