enhaced logging on error