Use repr of the error, or it cant be converted to JSON

Merge:	releng/9.1.0
(cherry picked from commit db1318fc87b2e3c6562265291a8add24ba9244f7)