0

I am receiving the following error when I make a GET request using jsonp in angularjs. Below is a code snippet being used :

        var url = 'https://ap-codereview.us.oracle.com/api/review-requests/' + 
                getCodereviewId(vm.details.codereview_url) + '?callback=JSON_CALLBACK';
        $http.jsonp(url).then(codereviewSuccessFn, codereviewErrorFn);

        function codereviewSuccessFn(data, status, headers, config) {
            vm.show = true;
            vm.codereviewDetails = data.data.review_request;
        }

        function codereviewErrorFn(data, status, headers, config) {
            vm.show = false;
            Snackbar.error(
                "Make sure you have accepted the security certificate warning when logging into codereview from chrome."+
                "Manually accept this warning."
                    + data.statusText + " : " + data.status);
                //Need logic here to differentiate above error from 404 NOT FOUND
                Snackbar.error(vm.details.codereview_url + " does not exist");
        }   

The response in the developer console on chrome shows me net::ERR_INSECURE_RESPONSE.

GET https://ap-codereview.us.oracle.com/api/review-requests/29113?callback=angular.callbacks._0 net::ERR_INSECURE_RESPONSE

I know why this error is happening, which is not my concern, however I need to configure the error message being displayed in the snackbar based on the error type, which is net::ERR_INSECURE_RESPONSE. I need to diffrentiate between the ERR_INSECURE_RESPONSE and 404 NOT FOUND messages in general.

My question is how can I access the ERROR type from the returned promise object ? I tried browsing through the object and only found a 404/error in the Status/StatusText.

Any help would be appreciated.

nitimalh
  • 919
  • 10
  • 26
  • As far as I know you can't get the actual 'net::' error, but `status` had a value of '0' when I get a 'net::ERR_CONNECTION_REFUSED' error. But this maybe browser specific. In some cases it is also possible that `status` is empty. – Sander_P Jul 28 '15 at 06:59
  • The status, headers and config elements are all undefined in both ERR_SECURE_RESPONSE and 404 NOT FOUND. – nitimalh Jul 28 '15 at 15:04
  • 2
    possible duplicate of [Determine if ajax call failed due to insecure response or connection refused](http://stackoverflow.com/questions/31058764/determine-if-ajax-call-failed-due-to-insecure-response-or-connection-refused) – Paul Sweatte Aug 07 '15 at 09:55

0 Answers0