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

status code is not provided when InvalidResponseError is obtained #20

Open
AlvaroVega opened this issue May 9, 2022 · 3 comments
Open

Comments

@AlvaroVega
Copy link

Cloned from conwetlab#54

status code is not provided when InvalidResponseError is obtained

https://github.com/conwetlab/ngsijs/blob/59ce53e2cfd7b486aa9580cbbc74dc339b134af2/dist/NGSI.js#L1687-L1691

InvalidResponseError could happens for example when PEP responses 401

Not sure if is really a bug or maybe just something that could be improved.
Others errors like InvalidRequestError are providing status code:

https://github.com/conwetlab/ngsijs/blob/59ce53e2cfd7b486aa9580cbbc74dc339b134af2/dist/NGSI.js#L1624-L1629

@aarranz
Copy link

aarranz commented Jul 11, 2022

Hi @AlvaroVega!

Thanks for reporting this.

I think adding the status code to the InvalidRequestError exception would be a great addition as usually this error is raised as the response status code is not one of the expected ones. In addition, we are going to provide also the body of the response. Both details should provide a good way to check what the problem is.

That said, I was thinking about the 401 error code, and I think that error response should not be managed with the InvalidRequestError. So we are working on adding an UnauthorizedError exception for those cases as well as an ForbiddenError exception for the 403 status code. What do you think?

@AlvaroVega
Copy link
Author

Absolutely, 401 and UnauthorizedError and 403 with ForbiddenError .
Thanks!

@fgalan
Copy link

fgalan commented Aug 23, 2022

@aarranz does PR #23 solves this issue? Has been included that PR in some (numbered) version of the library? Thanks!

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

No branches or pull requests

3 participants