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

improve error handling #230

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

improve error handling #230

wants to merge 1 commit into from

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.

@@ -275,6 +275,7 @@ struct aws_credentials *aws_parse_credentials_from_json_document(
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

@@ -42,9 +42,6 @@ struct aws_credentials_provider *aws_credentials_provider_new_anonymous(
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