Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RPCManager.setHandleErrorCallback

    Hello,

    For any case were a request fails and willHandleError is not set, I'd like to change the default behaviour to log to our application console rather than display a popup warning message; something like follows.

    Code:
            RPCManager.setHandleErrorCallback(new HandleErrorCallback() {
    
                @Override
                public void handleError(DSResponse response, DSRequest request) {
                    String error = response.getDataAsString();
                    logErrorToConsole(error);
                }
            });
    Essentially, I do not want it to do anything different than the default behaviour does today, except log the error to our console instead of a popup warning dialog.

    1) Is there anything else I should be doing in here to maintain what the default behaviour was doing?
    2) The javadoc says "By default handleError() always logs a warning"; are you doing something like SC.logWarn(response.getDataAsString())?
    3) Is it safe to always assume response.getDataAsString() is an error as String here? If not, how should I be handling that check.

    Thanks

    SmartClient Version: v9.1p_2014-11-09/Pro Deployment (built 2014-11-09)

    #2
    Right, we are doing SC.logWarn().

    "data" would not be a String for a validation error that wasn't handled by a component (eg, direct call to DataSource.updateData()). Bad server code could also return some kind of malformed response.

    Basically, be as circumspect as you can and don't assume types or non-null values, as you don't want your error handling code to compound the problem when something goes wrong :)

    Comment

    Working...
    X