Log errors before calling error contorller