Please use TUSCANY-1961, that is a sub-task of TUSCANY-2394. [1] https://issues.apache.org/jira/browse/TUSCANY-1961 [2] https://issues.apache.org/jira/browse/TUSCANY-2394
On Fri, Jul 11, 2008 at 11:05 AM, Dhaval Chauhan <[EMAIL PROTECTED]> wrote: > Hi Luciano, > > Thanks for the comments. > > Yes, I can provide the patch. Let me know the JIRA number once it's created. > > Thanks, > Dhaval > > > > ________________________________ >> Date: Fri, 11 Jul 2008 10:10:30 -0700 >> From: [EMAIL PROTECTED] >> To: [email protected] >> Subject: Re: Exception handling in store sample >> >> Hey Dhaval >> >> Thanks for looking into the issue. Let me try to give some comments >> inline. >> >> On Wed, Jul 9, 2008 at 5:34 PM, Dhaval Chauhan >> <[EMAIL PROTECTED]> wrote: >> > Hi, >> > >> > I was working on the scenarios for the JSON-RPC mentioned on the SCA >> > Java Web 2.0 Road map. I tried the first scenario i.e. 'Empty catalog >> > throws a Business Exception. Business Exception should properly >> > propagate and display nicely to client' >> > >> > I tried simulating the exception condition by making the .get() method >> > of the FruitsCatalogImpl.java throw the business exception. >> > >> > First I noticed that the JSON representation of the exception is not >> > being recognized by the browser js engine. >> > Currently, the Tuscany runtime is producing something like : >> > >> > "{\"id\":3,\"error\":services.ClientException: Fruits Catalog empty}" >> > >> > Instead, I think it should be : >> > "{\"id\":3,\"error\":{\"trace\":\"services.ClientException: Fruits >> > Catalog empty\",\"code\":490,\"msg\":\"Fruits catalog empty\"}}" >> > >> > Is it some issue related with the binding where the actual JSON error >> > message is formatted ? >> >> This is because we are handling errors as regular responses in >> JSONRPCServiceServlet. So, instead of just using the JSONResponse to >> return errors, we should use a JSONRPCResult, that would know how to >> properly marshal the exception in JSON format. >> >> I did a quick change in the servlet (handleJSONRPCMethodInvocation), >> and the following code allows me to get the proper exception in the >> client side. >> >> JSONRPCResult errorResult = new >> JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, e.getCause() ); >> return errorResult.toString().getBytes("UTF-8"); >> >> > >> > >> > After fixing this issue, I was still having issues with the exception >> > not being caught by the try/catch block, and I had to modify the >> > store.html client code as follow : >> > >> > function init() { >> > var item = new Array(); >> > try >> > { >> > item = catalog.get(); >> > } >> > catch(e) >> > { >> > alert(e.message); >> > return; >> > } >> > catalog_getResponse(item); >> > shoppingCart.get("", shoppingCart_getResponse); >> > } >> > >> >> As for the client code, how about the following pattern for the >> callback function : >> >> function shoppingTotal_getTotalResponse(total, exception) { >> if(exception) {alert(exception.message);} >> >> document.getElementById('total').innerHTML = total; >> } >> >> and the service call would continue with the same pattern we have been >> using, but would need to be surrounded by try/catch >> >> try { >> shoppingTotal.getTotal(shoppingTotal_getTotalResponse); >> //shoppingTotal_getTotalResponse(total); >> } catch (e) { >> alert(e); >> } >> >> >> Let me create a JIRA for this issue, and you could provide a clean >> patch with all necessary changes if you are interested. >> > >> > Thanks, >> > Dhaval >> > ________________________________ >> > The i'm Talkaton. Can 30-days of conversation change the world? Find out >> > now. >> >> >> >> -- >> Luciano Resende >> Apache Tuscany Committer >> http://people.apache.org/~lresende >> http://lresende.blogspot.com/ > > ________________________________ > Use video conversation to talk face-to-face with Windows Live Messenger. Get > started. -- Luciano Resende Apache Tuscany Committer http://people.apache.org/~lresende http://lresende.blogspot.com/
