move the check if uri is null above so that it will throw appropriate message if uri is empty, not 500 error