AppointmentExchanger.OnException Event
Occurs if an exception is raised during the export/import process.
Namespace: DevExpress.XtraScheduler.Exchange
Assembly: DevExpress.XtraScheduler.v24.1.Core.dll
NuGet Package: DevExpress.Scheduler.Core
Declaration
Event Data
The OnException event's data class is ExchangeExceptionEventArgs. The following 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. |
Remarks
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 AppointmentExchanger.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 AppointmentExchanger.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 Exception object is retrieved, to display the exception description.
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; // prevent this exception from throwing
}