my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Does it correct the way I catch the error? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does it correct the way I catch the error?" Watch "Does it correct the way I catch the error?" New topic
Author

Does it correct the way I catch the error?

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Dear friends,
I try to catch an error in this class but I am not sure about the palce that I put the try...catch.. could you please correct me if I am wrong in some part?
many thanks,
Elahe


Thanks,
Elahe
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

you probably want to throw the exception from the method if you don't want to deal with it.

or if it is normal ( not an error ) to have to a substring length greater than the length of the String then deal with it in the method to avoid the error.
The former is more of a "What the heck! a String shorter than the substring length! Stop the program, we have an error!" compared to the latter code block which is more of a "Just wanted to make sure the String was shorter than the specified max. Carry on."
Jamie
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Many thanks Jamie GOT IT GOT IT
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does it correct the way I catch the error?