# Catch RuntimeError

**URL:** <https://community.cesium.com/t/catch-runtimeerror/1361>\
**Category:** CesiumJS\
**Created:** [July 18, 2014, 2:22pm UTC](https://community.cesium.com/t/catch-runtimeerror/1361 "2014-07-18T14:22:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rencia\_Cloete](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@Rencia\_Cloete](https://community.cesium.com/u/Rencia_Cloete)\
**Post date:** [July 18, 2014, 2:22pm UTC](https://community.cesium.com/t/catch-runtimeerror/1361/1 "2014-07-18T14:22:33Z")

</div>

Hi , I have a long list of contextual maps that are available to user for imagery overlays. If many of these are added at one time at a certain point I get  
**RuntimeError: Program failed to link. Link log: Pixel shader sampler count exceeds MAX\_TEXTURE\_IMAGE\_UNITS (16).**

How do I trap this error so that I can disallow that final overlay but yet continue functioning? I do not call the rendering function myself, simply set show to true …

I would want to know WHICH overlay I was attempting at the time…

Function used to do the overlays:

var widget = new Cesium.CesiumWidget(‘cesiumContainer’);

var scene = widget.scene;

…

function addLayer(scene, url, layerName, alpha) {

var imageryLayers = scene.imageryLayers;

var provider = new Cesium.WebMapServiceImageryProvider({

url : url,

layers : layerName,

parameters : {

transparent : ‘true’,

format : ‘image/png’

},

proxy : new Cesium.DefaultProxy(‘proxy/?getUrl=’)

});

var newLayer;

try {

newLayer = imageryLayers.addImageryProvider(provider);

} catch (err){

alert(err.message);

return null;

}

var alphaSetting = alpha + 0;

newLayer.alpha = alphaSetting;

newLayer.show = true;

return newLayer;

}

Thanks!

Regards

Rencia

---

<div class="post-metadata">

**Author:** ![patrick](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/patrick/32/2045_2.png) [@patrick](https://community.cesium.com/u/patrick)\
**Post date:** [July 19, 2014, 2:41am UTC](https://community.cesium.com/t/catch-runtimeerror/1361/2 "2014-07-19T02:41:31Z")

</div>

This should no longer be an issue in Cesium 1.0, which will be released in August 1. In the meantime, you could test it by pulling down the master Cesium branch from github.

Patrick

---

<div class="post-metadata">

**Author:** ![Rencia\_Cloete](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@Rencia\_Cloete](https://community.cesium.com/u/Rencia_Cloete)\
**Post date:** [July 21, 2014, 7:55am UTC](https://community.cesium.com/t/catch-runtimeerror/1361/3 "2014-07-21T07:55:54Z")

</div>

Thanks Patrick. Seems prudent to wait till August 1. Hopefully I can trap the error then with a simple try-catch ye?  
Rgds

Rencia

---

<div class="post-metadata">

**Author:** ![Rencia\_Cloete](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@Rencia\_Cloete](https://community.cesium.com/u/Rencia_Cloete)\
**Post date:** [July 21, 2014, 7:59am UTC](https://community.cesium.com/t/catch-runtimeerror/1361/4 "2014-07-21T07:59:16Z")

</div>

Oh Pardon. I see the release notes for version 1 say:  
Cesium can now render an unlimited number of imagery layers, no matter how few texture units are supported by the hardware

Cheers
