0

I am developing a Sencha touch application using SAP 'Odata' proxy.

In my store I am calling the URL for READ operation

http:///sap/opu/odata/sap/TECHHELP/Tickets

I am loading the store manually in the controller using the following code

var ticketStore = Ext.getStore("Tickets");
var proxy=ticketStore.getProxy();

ticketStore.load(function(records, operation, success) {

        if(success){

        console.log('loaded records');
        }
        else{
          console.log('loading failed');
        }
    }, this);

When the application is executed in browser, in network tab I can see the format

Status Code:401 Unauthorized

Now when the URL is executed, I want to capture the exact status Code and the Message in the application.

I want to capture the possible error conditions by checking the status codes returned from server for Eg: 500,401,200,204

How Can I do this?

Regards,

P

1 Answer 1

2

this was helpful for me.

new Ext.data.Store({
model: "Your Model",
proxy:{
type: 'ajax',
url: "SomeURL",
reader: new Ext.data.JsonReader({
type: 'json',
root: 'SOME ROOT'
}),
listeners: {
exception:function (proxy, response,operation) {
  console.log(response.status);
  console.log(response.responseText); 
}
}
}
})

May be this will helpful for you.

Sign up to request clarification or add additional context in comments.

5 Comments

I tried to parse the response.text but it is null, I also tried to read operation.getError() that is an object but I am unable to read the error text.
Thanks,response.status gave the right error code. and "response.responseText" gave the response in xml, now when i try to fetch the message out of this response text using code "Ext.decode(response.responseText)" or "JSON.decode(response.responseText)" I get the error Uncaught Error: You're trying to decode an invalid JSON String: <?xml version="1.0" encoding="utf-8"?><error xmlns="schemas.microsoft.com/ado/2007/08/dataservices/… xml:lang="en">Value Tue Sep 03 2013 19:45:03 GMT+0530 (India Standard Time) does not represent a valid date/time</message></error>
I need to display the exact error returned by the server Value Tue Sep 03 2013 19:45:03 GMT+0530 (India Standard Time) does not represent a valid date/time from the entire response xml
If you try to parse a xml document use DOMParser. visit peachpit.com/articles/article.aspx?p=29307&seqNum=4
Thanks a lot for your help, using the DOMParser I was able to fetch the message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.