Suggestion on changing internal exception catch block

Oct 2, 2010 at 3:00 PM

Hi Darius

Sorry it's me again (hey please don't run away lol).

I am having trouble catching exceptions and after some time I figured out the reason.

 

The Situation (the simplified code: http://www.lulalala.com/temp/WindowsFormsApplication1.zip)

I am trying to validate the text (to see if it is valid regex). However I cannot do it using the SG validator.

I catch exceptions on the base level of WinForm: at Program.cs

I am using a CustomEvent.OnValueChanged to validate everytime something changed.

And when exception happenes, roughly the following will happen...

OnValueChanged() --> DoSomthing() --> !!!exception~!!! -->EditorBase/EditorControllerBase catches it (any exception) --> reverse the edit, blah blah bala--> my catch block will not get triggered :(

My proposed fix

The problem is that SG is catching exception which are generated outside itself:

So I am thinking of narrowing the catch criteria:

catch (Exception err) ---> catch (SourceGridException err)

However I am not sure if this can be a valid fix.

Can you see if this is okay, or if I can achive my goal without touching the SG source?

Thanks for your time!

lulalala

Coordinator
Oct 4, 2010 at 9:53 AM

Ehm..

> I am trying to validate the text (to see if it is valid regex). However I cannot do it using the SG validator.

 

I really so no reason why you can not validate cell input with regex.

 

 

>> I catch exceptions on the base level of WinForm: at Program.cs

What for is that? You should catch exceptions as early as possible, and not as late as possible