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

SourceProvider and ReactionProvider error message #41

Merged
merged 10 commits into from
Sep 23, 2024

Conversation

ruokun-niu
Copy link
Contributor

Description

  • Added more variants to DomainError
  • More validation checks and better error handling

Type of change

  • This pull request fixes a bug in Drasi and has an approved issue (issue link required).

Fixes: https://dev.azure.com/azure-octo/Incubations/_boards/board/t/Drasi/User%20Stories?workitem=13122

@agentofreality
Copy link
Contributor

@ruokun-niu does this include a unit test for the error that I reported to validate that it is resolved?

@ruokun-niu
Copy link
Contributor Author

@ruokun-niu does this include a unit test for the error that I reported to validate that it is resolved?

Hmm we actually don't have any unit tests for the control plane stuff. I manually tested this with some examples.
Maybe it's worth the time and effort now to add some tests? Or we can expand on our existing e2e test (the one in this repo) to add some scenarios that interact with SourceProvider/ReactionProvider?
@agentofreality

DomainError::NotFound => HttpResponse::NotFound().body("Resource not found"),
DomainError::Invalid { message } => HttpResponse::BadRequest().body(message),
DomainError::NotFound => HttpResponse::NotFound().body(" Resource not found"),
DomainError::Invalid { message } => HttpResponse::BadRequest().body(" ".to_string() + &message),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would we add a space to the beginning of the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think it's because when we did without the space, the response after using the CLI (e.g. response from a drasi apply command) will look a bit weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like the body message will be just concatenated with the status code, making it difficult to read

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the space should be in the CLI when it displays it. Otherwise, someone calling the API without the CLI will see error messages with a prefixed space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right good point. Thanks


#[error("JsonParseError")]
JsonParseError {
kind: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

is kind meant to be message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot why I used the word kind as I was trying to capture the type of the json value. Maybe message is a better choice

@ruokun-niu ruokun-niu merged commit 28fa764 into main Sep 23, 2024
32 checks passed
@danielgerlag danielgerlag deleted the source-provider-error branch September 26, 2024 00:11
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