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

Expose errors from the API endpoint in the UI #329

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ewanharris
Copy link
Contributor

@ewanharris ewanharris commented Mar 29, 2023

  • 704acab - While working on this change I realised that the highlighted text would not change on a re-render and it appeared to be down to passing HTML elements, so this commit refactors the Highlight component to a functional component and to also take the contents as a string rather than a children of HTML elements.
  • 462808c - Adds an error handler to the api-server that will massage the errors returned from express-oauth2-jwt-bearer into a JSON response for the UI. This is then handled in the frontend to try and pull the JSON (it's possible this could also be a raw HTML response) and then display it in an codeblock similar to the response

We could potentially extend this to also include examples of how to fix these issues.

For example:

The audience is different between the frontend and backend
Screenshot of the UI surfacing an invalid_token error

A developer extends this sample to include requiredScopes but does not update the frontend/update their token
Screenshot of the UI surfacing a insufficient_scope error

@ewanharris ewanharris requested a review from a team as a code owner March 29, 2023 14:01
@ewanharris ewanharris marked this pull request as draft March 29, 2023 14:01
@ewanharris ewanharris marked this pull request as ready for review March 29, 2023 14:06
apiError
});
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this isnt a bit too much for anyone using the sample to try and understand how to use our SDK. I know this isnt necessary related to our SDK, but not everyone might understand that.

In what event do we get back non-json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I realise now this is probably too much for the sample, the only case that raw HTML would be returned is when the server errors with something other than a token error. So maybe in that instance we can just ignore?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would argue we could abstract this in a component? That way it's all at least seperated from basic integration?

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.

None yet

2 participants