(function() {
  Ext.apply(gxp.plugins.LayerSource.prototype, {
    
    errorMessages: {
      404: 'Resorce not found.',
      403: 'Access denied.',
      302: 'Resource has been moved.'
    },

    errorMessageTitle: 'Some error while loading resource happend.',
    //Sorry for my bad english.

    //OVERRIDED exception listener added
    /** api: method[init]
     *  :arg target: ``Object`` The object initializing this plugin.
     *
     *  Calls :meth:`createStore` with a callback that fires the 'ready' event.
     */
    init: function(target) {
        this.target = target;
        this.createStore();
        if ( this.store ){
          this.store.on('exception', function(a,b,c,d,e,f){ console.log(arguments); this.showMessageError(b,e,f);},this);
        }
    },

    //Added exception message
    showMessageError: function(b,e,f) {
      Ext.MessageBox.show({
        title: this.errorMessageTitle,
        msg: b==='response'?f||this.errorMessages[e.status]:this.errorMessages[e.status],
        buttons: Ext.MessageBox.OK,
        icon: Ext.MessageBox.ERROR
      });

    }

  });

})();
