Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access the value of a FieldValue without throwing an exception #1

Closed
hazeliscoding opened this issue Jan 4, 2024 · 0 comments
Closed
Labels
bug Something isn't working enhancement New feature or request

Comments

@hazeliscoding
Copy link
Owner

hazeliscoding commented Jan 4, 2024

Issue

If we try to access a key that doesn't exist, we need to gracefully handle this if any error occurs or an exception is thrown.

How to Reproduce

var quickbaseClient = new QuickbaseClient("REALM_NAME", "USER_TOKEN");
var qbQuery = new QuickbaseQueryBuilder()
    .From("tableId")
    .Where($"{{'7'.CT.'{search}'}}")
    .Select([3, 7]) // We didnt select 150!!
    .Build();

var (response, errorResponse, isSuccess) = await quickbaseClient.QueryRecords(qbQuery);
if (!isSuccess)
{
    _logger.LogError($"Error querying Quickbase: {errorResponse?.Description} - {errorResponse?.Message}");
    return;
}

var dataFromQuery = response.Data.First();
worksheet.Cells["B5"].Value = qbResults["150"]?.Value; // This will throw an exception!!
@hazeliscoding hazeliscoding added bug Something isn't working enhancement New feature or request labels Jan 4, 2024
hazeliscoding pushed a commit that referenced this issue Jan 23, 2024
- Implement NullValueHandling.Ignore for JSON serialization
- Change Value property from dynamic to object for clarity
- Add GetValue<T>() method for type-safe value retrieval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant