better logging of errors