How can i catch a particular exception like IO exception.

How can i catch a particular exception like IO exception.

  
How can i catch a particular exception like IO exception.For example i am trying to read a file which does not exists.
Hi Pramod,

What component are you using to read the files?
Personally, I would first check if the file exists and then do the operation instead of letting it throw the exception.

And yes I'm a 100% defensor of Defensive programing: exceptions should be left for "exception situations" and if you need to treat it especially it turns into an "expected situation" so it should be protected instead of using exception handling.

Lets just not turn this thread into a discussion between defensive programing and exception based programing, both have they good and bad points and depends on each programmer/technology paradigma.

Regards,
João Rosado
João Rosado wrote:
Hi Pramod,

What component are you using to read the files?
Personally, I would first check if the file exists and then do the operation instead of letting it throw the exception.

And yes I'm a 100% defensor of Defensive programing: exceptions should be left for "exception situations" and if you need to treat it especially it turns into an "expected situation" so it should be protected instead of using exception handling.

Lets just not turn this thread into a discussion between defensive programing and exception based programing, both have they good and bad points and depends on each programmer/technology paradigma.

Regards,
João Rosado
 Is there a way to do it though ?
 
When you trap the exception, look at the message
Hi Pramod,

If the exception is triggered in OutSystems, it can be typed, so you can catch that particular type.

If the exception is triggered in an extension (.NET / Java code), you may have to catch all exceptions and then parse the error message. If you have access to the source code, you may consider changing it so it returns an error code instead of throwing an exception.