not sure if it will work in your script, but try adding the following to your web.config under <system.web> :
<system.web> <customErrors mode="Off" /> ... </system.web>
works in my instance.
also see:
CustomErrors mode = "Off"
jim tollan Jul 26 2018-12-12T00: 00Z
source share