Altered logError function to both log and throw the error, without need for separate throw call