Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Exception Handling #631


User avatar
0
cangunaydin created

Hi, I have a problem with exception handling sometimes i need to disable javascript error exception handling. For ex. I send some ajax request to another server and i don't have any control on return values so in the return json there is no "success" property. As a result it displays me modal which has error. How i can disable this? Any solution for that?


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    You can directly use $.ajax, instead of abp.ajax (which handles exceptions). I suggest this.

    But, normally ABP understand if there is no success property and calls your done handler (see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Resources/Abp/Framework/scripts/libs/abp.jquery.js#L71">https://github.com/aspnetboilerplate/as ... ery.js#L71</a>). Are you sure that it's not working?

  • User Avatar
    0
    cangunaydin created

    Hi, I don't have the path ~/Abp/Framework/scripts/libs/abp.jquery.js

    Instead of that i have /Abp/Framework/scripts/libs/angularjs/abp.ng.js and it has this method

    handleResponse: function (response, defer) { var originalData = response.data;

            if (originalData.success === true) {
                response.data = originalData.result;
                defer.resolve(response);
    
                if (originalData.targetUrl) {
                    abp.ng.http.handleTargetUrl(originalData.targetUrl);
                }
            } else if(originalData.success === false) {
                var messagePromise = null;
    
                if (originalData.error) {
                    messagePromise = abp.ng.http.showError(originalData.error);
                } else {
                    originalData.error = defaultError;
                }
    
                abp.ng.http.logError(originalData.error);
    
                response.data = originalData.error;
                defer.reject(response);
    
                if (originalData.unAuthorizedRequest) {
                    abp.ng.http.handleUnAuthorizedRequest(messagePromise, originalData.targetUrl);
                }
            }
        }
    

    This happens when we use ng-file-upload plugin. When you cancel the upload it triggers the modal.

  • User Avatar
    0
    cangunaydin created

    Hello, Sorry my bad about ~/Abp/Framework/scripts/libs/abp.jquery.js it is over there but when i add break point, it doesn't get in to the break point instead of that it enters the breakpoint that i have put to abp.ng.js it just enters this function 'responseError': function (ngError) { var error = { message: ngError.data, details: ngError.statusText, responseError: true }

                        abp.ng.http.showError(error);
    
                        abp.ng.http.logError(error);
    
                        return $q.reject(ngError);
                    }