Link to home
Start Free TrialLog in
Avatar of mrayandutta
mrayandutta

asked on

Spring Rest Template exception handling

Hi ,
I am using Spring Rest Template for invoking a web service .
I want to handle all types of exceptions returned by Rest Template .
Any body has some proper links/sample code describing the exception handling scenario using Spring Rest Template ?
Regards,
Ayan
Avatar of mccarl
mccarl
Flag of Australia image

There really isn't anything too special about it, this link may help, http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/remoting.html#rest-resttemplate, but you may have already come across it.

If the above doesn't help, can you please elaborate more on what you are trying to do, any issues that you are coming across, etc something more specific for us to provide help on?
Avatar of GuruJava
GuruJava

Avatar of mrayandutta

ASKER

Hi ,
Thanks to both you for your replies .

@mccarl

In my application there is an Ajax call to a spring controller .
This controller calls RestTemplate and in turn returns the output received from the ResTemplate as the Ajax response .

For any exception occurring  at the REST Template end, the controller needs to pass the response code only as the Ajax response .
So if there is any exception in the RestTemplate invocation ,I need to get the response code of the rest template (say 404 or 500 ) and  the controller would return the error code to its invoker .

But as the exceptions of Rest Template seems to be unchecked ,this task seems bit complicated .
I hope that explains my scenario a bit .

Regards,
Ayan
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help
No worries!