Fix handling of errors in term