In Distributable environment,what happens if our component throws an exception(may be checked/unchecked) to others who r using our component. we must handle here itself or let it leave to others to handle? plz. reply soon

Showing Answers 1 - 10 of 10 Answers

Tijo

  • Dec 9th, 2005
 

Hi,

With my little knowledge, i think we need to handle it. In a distributed environment the  object which is been called will be a proxy object to the remote object. So it will be better to handle the error in your component.

Cheers

  Was this answer useful?  Yes

Soccer Dude

  • Dec 10th, 2005
 

You know how the exception is to be handled, so handle the exception.  You, however, need to let the caller know that an exception had occurred and to take appropriate actions inform the user of the error.

  Was this answer useful?  Yes

Ashish

  • Dec 13th, 2005
 

It depends on the context of the exception. But usually you may want to wrap the exception in a meaningful way and let the caller know about it. (That's the transparent way of working.) Make sure that the message that the client sees is something that makes sense to the client. For example, if your component uses a configuration file, then it will obviously throw a FileNotFoundException when it does not find the file. It's a good idea to let the client know which component needed that file and possibly the purpose i.e. configuration. So, a message like "Component XXX is not able to find its configuration file at this location: YYY" is better than the default FileNotFoundException message.

  Was this answer useful?  Yes

If your component throws an exception, in most cases we should not catch the exception, otherwise the calling component will never know that an exception has occured.

What we should do is to force the user of our component to handle the exception, so that we can use the stack trace for debugging purpose.

  Was this answer useful?  Yes

Mahesh Tpt

  • Nov 5th, 2007
 

In exception handling, we should use throw clause to throw the exception because exceptions in java are throwable. If any method calls the throw clause, it(throw clause) will tell "If you call me, You must have handle the exception".

So in this situation, the caller of that method must have that exception.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions