…
it happens when you try to delete ‘current’ layer. to avoid the issue you have to set default layer as current. something:
if (cur = LayerManager.getLayerFromName "0") != undefined do cur.current = on