Skip to content

Conversation

@TingDaoK
Copy link
Contributor

@TingDaoK TingDaoK commented Feb 14, 2024

  • raise proper error if error raise is missing
  • Now the allocation can't fail, don't handle it.

TODO

Same thing for all the other repos. not finishing it as other stuff is more high priority, and too many of those.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

struct aws_json_value *document_root = aws_json_value_new_from_string(allocator, document);
if (document_root == NULL) {
AWS_LOGF_ERROR(AWS_LS_AUTH_CREDENTIALS_PROVIDER, "Failed to parse document as Json document.");
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
Copy link
Contributor

@graebm graebm Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should fix this in aws-c-common
aws_json_value_new_from_string() ought to raise an error
and that error should be AWS_ERROR_INVALID_JSON, which would be more useful than INVALID_ARGUMENT


struct aws_credentials_provider *provider = aws_mem_calloc(allocator, 1, sizeof(struct aws_credentials_provider));

struct aws_credentials *credentials = aws_credentials_new_anonymous(allocator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine here, but I think it would be better to keep the null check as a design pattern. What if this function starts failing in the future? We should not make assumptions about the return value at this level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants