I implemented an event receiver and attached it to a MOSS 2007 document library. I overrode the synchronous itemUpdating method and perform some validation before letting the update operation proceed. In case validation fails, I use the following code to cancel the update and indicate an error to the user:
public override void ItemUpdating(SPItemEventProperties properties) { base.ItemUpdating(properties); // Perform some validation... if (/*validation fails*/) { properties.Status = SPEventReceiverStatus.CancelWithError; // line 1 properties.Cancel = true; // line 2 properties.ErrorMessage = "Validation error"; // line 3 } } I expected to see the SharePoint error page with a display of the error message. Instead, I see the rather unamiable IIS server error page with the full stack trace.
I switched around lines 2 and 3, and I even replaced SPEventReceiverStatus.CancelWithError with SPEventReceiverStatus.CancelNoError, to no avail. Any ideas???