How do I insert a parameter into the ExceptionMessage?

Topics: Exception Handling Application Block
Jul 8, 2008 at 7:44 PM
Hi
I'm using a Wrap Handelr inside a wrap policy but I want to display a slightly different mesage per each entity that uses that policy:
"The {0} already exists in the system", entityName
Is there a way to do it? It seems not realistic to create a policy per each entity that throws that exception...
Thank you,
Ken
Jul 8, 2008 at 9:20 PM
Hi,

There is not built it support for this, so you'll need a custom handler. Tom Hollander posted an enhanced handler to map SQL errors to messages; while it's not quite the same you're looking for, it still shows the basic approach.

Fernando


ken_saraf wrote:
Hi
I'm using a Wrap Handelr inside a wrap policy but I want to display a slightly different mesage per each entity that uses that policy:
"The {0} already exists in the system", entityName
Is there a way to do it? It seems not realistic to create a policy per each entity that throws that exception...
Thank you,
Ken


Jul 9, 2008 at 8:53 PM

Thank you.

What Tom did is cool but it's beyond my needs. Was it the intention of EHAP design that for every diffrent exception message I would create a different wrap policy? It doesn't make much sense...
Ken


fsimonazzi wrote:
Hi,

There is not built it support for this, so you'll need a custom handler. Tom Hollander posted an enhanced handler to map SQL errors to messages; while it's not quite the same you're looking for, it still shows the basic approach.

Fernando


ken_saraf wrote:
Hi
I'm using a Wrap Handelr inside a wrap policy but I want to display a slightly different mesage per each entity that uses that policy:
"The {0} already exists in the system", entityName
Is there a way to do it? It seems not realistic to create a policy per each entity that throws that exception...
Thank you,
Ken





Jul 10, 2008 at 12:43 PM

Hi Ken,

I think the best in your situation would be a handler that could extract information from the exception to build the message, that's why I pointed you to Tom's implementation. Do you think something like the logging block's formatters would help you here?

Fernando


ken_saraf wrote:

Thank you.

What Tom did is cool but it's beyond my needs. Was it the intention of EHAP design that for every diffrent exception message I would create a different wrap policy? It doesn't make much sense...
Ken


fsimonazzi wrote:
Hi,

There is not built it support for this, so you'll need a custom handler. Tom Hollander posted an enhanced handler to map SQL errors to messages; while it's not quite the same you're looking for, it still shows the basic approach.

Fernando


ken_saraf wrote:
Hi
I'm using a Wrap Handelr inside a wrap policy but I want to display a slightly different mesage per each entity that uses that policy:
"The {0} already exists in the system", entityName
Is there a way to do it? It seems not realistic to create a policy per each entity that throws that exception...
Thank you,
Ken