Layer onLoad event, how to handle an error

Discussion created by webskister on Nov 3, 2010
Latest reply on Dec 17, 2010 by hzhu
So to load a layer is straight forward as taken from the "JavaScript API Concepts" page. Sniplet below...

function init() {
  var layer = new esri.layers.ArcGISDynamicMapServiceLayer(...);
  dojo.connect(layer, "onLoad", printInitialExtent);

How do you catch an event if the layer never gets loaded? Maybe the service is down. If the layer does not get loaded I want to inform the user (rather than a blank map).