fix error handling. add way to inject custom error handler