Fix get_by_name to not swallow all database errors

This causes generic database errors to bubble up rather than returning a
LookupException.