Fix error reporting to use real error object