improved error handling for webgl context