updated error logging to include error message and codes