LMap goes grey if URL fails - how can I catch the exception and post a grey

We have:

lmap.addBaseLayer(new LTileLayer(myURL));

The problem is that in some cases we can get an unauthorized error code (401) if the user is trying to search for something outside of the services we’re authorized to access. I can’t seem to find a way to catch the 401 error and instead of displaying a grey box perhaps fire a popup notification letting the user know they are out going out of bounds.