fix error object reference in try/catch block