Handling possible exception in stringification of window.location. Fixes issue 3908