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

Create ODataError in Non-Success responses #2341

Merged
merged 26 commits into from
Dec 16, 2020

Conversation

KenitoInc
Copy link
Contributor

@KenitoInc KenitoInc commented Nov 2, 2020

Issues

This pull request fixes issue #2331 .

Description

When we return error messages from the controller e.g

BadRequest("Error Message");
Conflict("Error Message");
Unauthorized("Error Message");
NotFound("Error Message");

The Error Message is serialized as a string and the response is as follows:

{
  "@odata.context":"https://ServiceUri/odata/$metadata#Edm.String",
  "value":"Error Message"
}

In this PR, we add Custom methods in the ODataController that allows us to Create an ODataError from the Error Message hence the response will be Serialized as an Error to achieve the response below:

{
  "error": {
    "code": "400",
    "message": "Error Message"
  }
}

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

@xuzhg
Copy link
Member

xuzhg commented Nov 6, 2020

@KenitoInc Thanks for your PR, Yes, it's based on our discussion. However, i'd like to re-think it again.
The question is that: "Do we need to provide these method "NotFound(), BadRequest()" at our side? or Can our customer to implement it at customer side?"
I'd like to involve @mikepizzo to share his thought.

Copy link
Member

@xuzhg xuzhg left a comment

Choose a reason for hiding this comment

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

🕐

// Arrange
#if NETCORE
const string expectedResponse = "{\"error\":{\"code\":\"400\",\"message\":\"Update failed\"}}";
#else
Copy link
Member

Choose a reason for hiding this comment

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

need several E2E

@KenitoInc KenitoInc marked this pull request as ready for review December 11, 2020 18:30
@KenitoInc KenitoInc requested a review from xuzhg December 11, 2020 18:30
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.

4 participants