DWR

Improved Exception Handling

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 3.0.M1
  • Fix Version/s: 3.0.RC2
  • Component/s: Core, Engine
  • Description:
    Hide
    It would be very nice to be able to register handlers for individual exceptions outside the scope of the default error handler. For example:

    {code}
       <convert converter="exception" javascript="MyException" class="com.example.MyException"/>
    {code}

    {code}
    window.onload = function() {
        
        dwr.engine.registerExceptionHandler(MyException, function() {
            alert("Hello world");
        });

        dwr.engine.registerExceptionHandler('com.example.MyException', function() {
            alert("Same thing");
        });

    };
    {code}

    It would also be nice to be able to chain the exception handlers. I modified engine.js so that if an exception handler returns "true", the engine will continue to go up the "chain" of exception handlers. The chain is:

    1.) The exception handler registered with the call
    2.) The exception handler registered for the given exception
    3.) The default error handler

    This is *extremely* useful for cases where a call would want to do something in case of a failure (say hiding a "Saving..." message) but does not want to fully handle the exception.
    Show
    It would be very nice to be able to register handlers for individual exceptions outside the scope of the default error handler. For example: {code}    <convert converter="exception" javascript="MyException" class="com.example.MyException"/> {code} {code} window.onload = function() {          dwr.engine.registerExceptionHandler(MyException, function() {         alert("Hello world");     });     dwr.engine.registerExceptionHandler('com.example.MyException', function() {         alert("Same thing");     }); }; {code} It would also be nice to be able to chain the exception handlers. I modified engine.js so that if an exception handler returns "true", the engine will continue to go up the "chain" of exception handlers. The chain is: 1.) The exception handler registered with the call 2.) The exception handler registered for the given exception 3.) The default error handler This is *extremely* useful for cases where a call would want to do something in case of a failure (say hiding a "Saving..." message) but does not want to fully handle the exception.
  1. dwr-261.patch
    (3 kB)
    Kevin Conaway
    07/Jul/08 6:01 PM

Issue Links

Activity

Hide
Kevin Conaway added a comment - 07/Jul/08 6:01 PM

Attaching patch

Show
Kevin Conaway added a comment - 07/Jul/08 6:01 PM Attaching patch
Hide
David Marginian added a comment - 12/Feb/09 6:00 PM

Kevin revived this issue (actually 279) on the mailing list. My personal opinion is that we shouldn't do this in DWR. Why bloat the DWR code base when this can be handled well by the user. Here is an example of what I am talking about:

function getDataFromServer() {
dwrService.getAddress({
callback: getDataFromServerCallBack,
errorHandler: function(message, exc) {
handleError({ callLevelFunction: handleCallError, callLevelFunctionArgs: ["test"], message: message, exception: exc })
}
});
}

// Re-usable "global" error handle.
function handleError(argObject) { // Retrieve the local call function and execute it. var callLevelFunctionToExecute = argObject.callLevelFunction; callLevelFunctionToExecute.apply(this, argObject.callLevelFunctionArgs); // Now write the code that will apply to all errors here. alert("global - do whatever here."); }

// Handle a specific calls error
function handleCallError(args) { alert(dwr.util.toDescriptiveString(args)); }

Show
David Marginian added a comment - 12/Feb/09 6:00 PM Kevin revived this issue (actually 279) on the mailing list. My personal opinion is that we shouldn't do this in DWR. Why bloat the DWR code base when this can be handled well by the user. Here is an example of what I am talking about: function getDataFromServer() { dwrService.getAddress({ callback: getDataFromServerCallBack, errorHandler: function(message, exc) { handleError({ callLevelFunction: handleCallError, callLevelFunctionArgs: ["test"], message: message, exception: exc }) } }); } // Re-usable "global" error handle. function handleError(argObject) { // Retrieve the local call function and execute it. var callLevelFunctionToExecute = argObject.callLevelFunction; callLevelFunctionToExecute.apply(this, argObject.callLevelFunctionArgs); // Now write the code that will apply to all errors here. alert("global - do whatever here."); } // Handle a specific calls error function handleCallError(args) { alert(dwr.util.toDescriptiveString(args)); }
Hide
David Marginian added a comment - 12/Feb/09 6:18 PM

Also, I don't think this is a major priority.

Show
David Marginian added a comment - 12/Feb/09 6:18 PM Also, I don't think this is a major priority.
Hide
David Marginian added a comment - 10/Dec/10 8:40 PM

Very similar to DWR-279.

Show
David Marginian added a comment - 10/Dec/10 8:40 PM Very similar to DWR-279.
Hide
David Marginian added a comment - 10/Dec/10 8:40 PM

Any work that we decide to do here will be done in DWR-279.

Show
David Marginian added a comment - 10/Dec/10 8:40 PM Any work that we decide to do here will be done in DWR-279.

People

Dates

  • Created:
    07/Jul/08 5:59 PM
    Updated:
    15/Feb/11 5:59 AM
    Resolved:
    10/Dec/10 8:40 PM