You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Kevin Radloff (JIRA)" <ji...@apache.org> on 2012/10/01 23:01:36 UTC

[jira] [Created] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Kevin Radloff created THRIFT-1706:
-------------------------------------

             Summary: jquery ajax code doesn't handle exceptions
                 Key: THRIFT-1706
                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
             Project: Thrift
          Issue Type: Bug
          Components: JavaScript - Library
    Affects Versions: 0.9
            Reporter: Kevin Radloff


The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.

It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500564#comment-13500564 ] 

Henrique Mendonca commented on THRIFT-1706:
-------------------------------------------

"Normal" exceptions can be catch using the error() handler, please see: https://github.com/apache/thrift/blob/trunk/lib/js/test/test.js#L402
It that what you mean? it's similar to the jQuery AJAX mechanism...

It's unfortunate it's not yet in the JS tutorial, but patches are always welcome ;)

ps: no error or complete is called when nothing comes back, and this fix would be an improvement...
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Kevin Radloff (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500638#comment-13500638 ] 

Kevin Radloff commented on THRIFT-1706:
---------------------------------------

Ooh, I see. In my case I was simply doing it wrong, not providing an error handler and/or expecting it to take one argument instead of three. In my case, I'm concerned about thrift-generated-API exceptions returned by the server, and so these are raised just fine in all circumstances, even for CORS (since the request has to have completed successfully for them to trigger). Thanks for pointing me at the existing test.
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Kevin Radloff (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500576#comment-13500576 ] 

Kevin Radloff commented on THRIFT-1706:
---------------------------------------

Hmm... Part of the problem here may be that jQuery doesn't call the error handler for cross-domain requests, which is what I'm doing.
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500269#comment-13500269 ] 

Henrique Mendonca commented on THRIFT-1706:
-------------------------------------------

Cheers Øyvind.
Would you guys have a test case for it? e.g. ideally a qunit test like on https://github.com/apache/thrift/blob/trunk/lib/js/test/test.js
Perhaps if you send an argument of a wrong type you might be able to reproduce it... or do you have a different scenario?
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Kevin Radloff (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500542#comment-13500542 ] 

Kevin Radloff commented on THRIFT-1706:
---------------------------------------

The scenario is calling an API that raises exceptions. :) As one would expect, the generated javascript raises exceptions when one is received from the server. However, in the jQuery AJAX request code path, this is done inside the callback handler on the request object, where it simply gets swallowed up. See https://github.com/apache/thrift/blob/trunk/lib/js/thrift.js#L234
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500597#comment-13500597 ] 

Henrique Mendonca commented on THRIFT-1706:
-------------------------------------------

Ah Ok, cross-domain is complicated!
you might still be able to do it by requesting it manually: https://github.com/apache/thrift/blob/trunk/lib/js/test/test.js#L272
and using cross-origin resource sharing on latest browsers, you can google it but it's a little out of the scope here.
Unless you want to integrate it as an optional thrift transport, which kind of sounds interesting!
If you don't mind I'll close this ticket and you can use the mail list for further discussions.
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Øyvind Smestad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13500251#comment-13500251 ] 

Øyvind Smestad commented on THRIFT-1706:
----------------------------------------

I also hit this issue, one possible solution to get this working with one callback is to modify thrift.js (version 0.9) from line 242:
{code:JavaScript}
success: jQuery.makeArray(args).pop(),
error: function (jqXHR, textStatus, errorThrown) {
  var callback = jQuery.makeArray(args).pop();
  callback.call(this, errorThrown);
}
{code}
This makes jQuery call the callback (with the error thrown by remote method) instead of dropping it on the floor and pretending nothing happend.
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Closed] (THRIFT-1706) jquery ajax code doesn't handle exceptions

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1706?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henrique Mendonca closed THRIFT-1706.
-------------------------------------

    Resolution: Not A Problem

Please, feel free to re-open it if you find something else or have a patch for the improvement.

Cheers,
Henrique
                
> jquery ajax code doesn't handle exceptions
> ------------------------------------------
>
>                 Key: THRIFT-1706
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1706
>             Project: Thrift
>          Issue Type: Bug
>          Components: JavaScript - Library
>    Affects Versions: 0.9
>            Reporter: Kevin Radloff
>
> The converter function inside of the jquery ajax handler makes no accommodations for exceptions that may be thrown during the normal course of running "recv_method.call()" for a remote method that raises an exception. If this happens, the result gets lost as the normal ajax response handling is aborted.
> It seems like the converter function should at the very least have a try/catch block that sets the exception as the ajax result in the place of a regular thrift type/object. It might be best to have some sort of interface that takes both a callback and errback, however, so as to not require introspection into the result.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira