code: function() {
          var img = this.imgDiv;
          if (img.src != null) {
              this.imageReloadAttempts++;
              if (this.imageReloadAttempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
                  this.setImgSrc(this.layer.getURL(this.bounds));
              } else {
                  OpenLayers.Element.addClass(img, "olImageLoadError");
                  this.events.triggerEvent("loaderror");
                  this.onImageLoad();
              }
          }
      }
docs: Method: onImageError
  Handler for the image onerror event