Hi All.

I am testing Microsoft Enterprise Library - June 2005 Exception
Handling, and I am trying to pass parameters to HandleException Method,
and recieve it in my implementation of the abstract class.
However, it seems that the HandleException can only implement:

public abstract Exception HandleException(
Exception exception,
string policyName,
Guid handlingInstanceId
And that you can not add your own override implementation.

Does some one knows if this doable and how ?

What I tried to do is to implement the HandleException by adding more
parameters after the GUID parameter. The problem is that it would not
compile.

Example

void func(string strData)
{
try
{
...
}
catch(Exception e)
{
ExceptionPolicy.HandleException(e,"DAL",strData);
}
}

Re: Passing parameters to HandleException by Nick

Nick
Sun Jul 24 14:46:07 CDT 2005

what would be the point of creating an implementation of a type if you don't
intend to keep the same interface?

The entire point of the Liskov Substitution Principle is that the framework
(the Exception Handling Application Block) is not aware of which of the
exception handlers it is using. They all have to behave in the same way.
That includes yours.

I haven't studied the block in detail. I assume that the ExceptionPolicy
object provides the static call to HandleException. If so, you are using
someone elses code to call yours. To do so, you have to conform to the
interface imposed by that code.

Do you see what I'm getting at?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Gil" <gil@upsteed.com> wrote in message
news:1121862656.166265.206260@f14g2000cwb.googlegroups.com...
> Hi All.
>
> I am testing Microsoft Enterprise Library - June 2005 Exception
> Handling, and I am trying to pass parameters to HandleException Method,
> and recieve it in my implementation of the abstract class.
> However, it seems that the HandleException can only implement:
>
> public abstract Exception HandleException(
> Exception exception,
> string policyName,
> Guid handlingInstanceId
> And that you can not add your own override implementation.
>
> Does some one knows if this doable and how ?
>
> What I tried to do is to implement the HandleException by adding more
> parameters after the GUID parameter. The problem is that it would not
> compile.
>
> Example
>
> void func(string strData)
> {
> try
> {
> ...
> }
> catch(Exception e)
> {
> ExceptionPolicy.HandleException(e,"DAL",strData);
> }
> }
>



Re: Passing parameters to HandleException by Gil

Gil
Mon Jul 25 10:50:56 CDT 2005

Yes, Nick

I see your point.

I want to enjoy the app block library, but I also want to pass a param
that will enable my programmers to send their own message to my logging
system.
I guess I will probably implement my own Exception class that will be
inherited from exception, and include their option to add customized
messages to the Exception Handler, when I will probably cast them back
using inner Exception.

Gil.


Nick Malik [Microsoft] wrote:
> what would be the point of creating an implementation of a type if you don't
> intend to keep the same interface?
>
> The entire point of the Liskov Substitution Principle is that the framework
> (the Exception Handling Application Block) is not aware of which of the
> exception handlers it is using. They all have to behave in the same way.
> That includes yours.
>
> I haven't studied the block in detail. I assume that the ExceptionPolicy
> object provides the static call to HandleException. If so, you are using
> someone elses code to call yours. To do so, you have to conform to the
> interface imposed by that code.
>
> Do you see what I'm getting at?
>
> --
> --- Nick Malik [Microsoft]
> MCSD, CFPS, Certified Scrummaster
> http://blogs.msdn.com/nickmalik
>
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a
> programmer helping programmers.
> --
> "Gil" <gil@upsteed.com> wrote in message
> news:1121862656.166265.206260@f14g2000cwb.googlegroups.com...
> > Hi All.
> >
> > I am testing Microsoft Enterprise Library - June 2005 Exception
> > Handling, and I am trying to pass parameters to HandleException Method,
> > and recieve it in my implementation of the abstract class.
> > However, it seems that the HandleException can only implement:
> >
> > public abstract Exception HandleException(
> > Exception exception,
> > string policyName,
> > Guid handlingInstanceId
> > And that you can not add your own override implementation.
> >
> > Does some one knows if this doable and how ?
> >
> > What I tried to do is to implement the HandleException by adding more
> > parameters after the GUID parameter. The problem is that it would not
> > compile.
> >
> > Example
> >
> > void func(string strData)
> > {
> > try
> > {
> > ...
> > }
> > catch(Exception e)
> > {
> > ExceptionPolicy.HandleException(e,"DAL",strData);
> > }
> > }
> >