Refactor type_from_string() to allow continuing after detecting an error