|
Home > Archive > Microsoft Content Management Server > July 2005 > Problem with throwing own error on CmsPosting_Deleting event
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Problem with throwing own error on CmsPosting_Deleting event
|
|
| britman@gmail.com 2005-07-27, 7:50 am |
| Hi
Hoping someone can help with this.
I have the following code
public void CmsPosting_Deleting(Object sender, ChangingEventArgs e)
{
if (e.Action==PublishingAction.Delete)
{
try
{
throw new Exception("You do not have authorisation.")
}
catch (Exception ex)
{
e.Cancel = true;
e.SuppressExceptionOnCancel = true;
WebAuthorErrorEventArgs error = new
WebAuthorErrorEventArgs("FailedDelete",ex);
error.Title = "Delete Declined";
WebAuthorContext.Current.RaiseErrorEvent(error);
}
}
}
Which is basically hooking into the MCMS console delete event and
trying to throw a custom error in the Console Error control when the
user doesn't have authorisation to delete something. However when the
code runs it seems to not display the error (the code does definately
run) and returns to the parent channel of the posting that was selected
to be deleted.
If I dont set the e.SuppressExceptionOnCancel to true the standard
error displays correctly so I was hoping someone could spot where I am
going wrong???
Thanks
| |
| Stefan [MSFT] 2005-07-27, 5:52 pm |
| Hi,
if SuppressExceptionOnCancel is set then the exception is consumed silently.
So you will not see the error message of your exception.
You could present this error in a label control if you like.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
<britman@gmail.com> wrote in message
news:1122469037.464657.221530@g43g2000cwa.googlegroups.com...
> Hi
>
> Hoping someone can help with this.
>
> I have the following code
>
> public void CmsPosting_Deleting(Object sender, ChangingEventArgs e)
> {
> if (e.Action==PublishingAction.Delete)
> {
>
> try
> {
> throw new Exception("You do not have authorisation.")
> }
> catch (Exception ex)
> {
> e.Cancel = true;
> e.SuppressExceptionOnCancel = true;
> WebAuthorErrorEventArgs error = new
> WebAuthorErrorEventArgs("FailedDelete",ex);
> error.Title = "Delete Declined";
> WebAuthorContext.Current.RaiseErrorEvent(error);
> }
> }
> }
>
> Which is basically hooking into the MCMS console delete event and
> trying to throw a custom error in the Console Error control when the
> user doesn't have authorisation to delete something. However when the
> code runs it seems to not display the error (the code does definately
> run) and returns to the parent channel of the posting that was selected
> to be deleted.
> If I dont set the e.SuppressExceptionOnCancel to true the standard
> error displays correctly so I was hoping someone could spot where I am
> going wrong???
>
> Thanks
>
|
|
|
|
|