Unfortunately we cannot guarantee that the server will process our stores' requests correctly 100 percent of the time. When the server returns an error or fails to respond, it's useful to be ready to inform our users that something has not worked as expected and perhaps perform extra processing or tidying up. This recipe demonstrates how to handle proxy exceptions and present an error message to the user.
To demonstrate exception handling you will need to ensure that you have a running web server to host the example and serve the provided error-response.json
file.
Define the Model that we will attempt to load data into:
Ext.define('Book', { extend: 'Ext.data.Model', fields: [{ name: 'Title', type: 'string' }] });
Add an AJAX Proxy to the Model, defining the
url
config option aserror-response.json
:Ext.define('Book', { ... proxy: { type: 'ajax', url: 'error-response.json' } });
Listen...