improve error handling
authored by willdot.net and committed by Tangled 2 weeks ago c39156f1 079a1de0