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

WhatsappApiException not expose the status code #107

Closed
pcomp96 opened this issue Aug 3, 2023 · 3 comments
Closed

WhatsappApiException not expose the status code #107

pcomp96 opened this issue Aug 3, 2023 · 3 comments

Comments

@pcomp96
Copy link
Contributor

pcomp96 commented Aug 3, 2023

Hi @Bindambc,

I resumed developing the integration I was implementing, while I was wrapping the CRUD API of the whatsapp media files to expose them to the integrating system, I noticed that the WhatsappApiException class has the WhatsappApiError object as a private member. It does not have a method that returns the status code of the checked exception. Being a REST call, it would need a getStatusCode method at least to return the status code occurred in the call.

The API I'm testing is the retrieveMediaUrl by mediaId.

image

When I call the API with an ID that doesn't exist I would like to return 404 from my API but I have no way to discriminate that

image

Using a provider, In this case, i catch the exception but i have to return 500 because i don't have the status code.

The exception I get is the following.

image

Would it be expensive to add a statusCode return?

Waiting for your reply, I hope I was helpful.

Thank you,
Giuseppe

@Bindambc
Copy link
Owner

Bindambc commented Aug 4, 2023

Hello @pcomp96 ,

I can modify the class WhatsappApiException by adding a method called getWhatsappApiError() that will allow obtaining the error object. Within the error object, you will be able to check the error codes sent by WhatsApp API.

Could this help you?

image

@Bindambc
Copy link
Owner

Bindambc commented Aug 4, 2023

@pcomp96
I could also return the HTTP code, but I'm not sure if it would be helpful. Note that in the case of media not found, the HTTP code is 400.
image

@pcomp96
Copy link
Contributor Author

pcomp96 commented Aug 21, 2023

Sorry for the late reply @Bindambc,

I can modify the class WhatsappApiException by adding a method called getWhatsappApiError() that will allow obtaining the error object. Within the error object, you will be able to check the error codes sent by WhatsApp API.

Yes is perfect because the class WhatsappApiException return only the message of the exception throwed from API.

I could also return the HTTP code, but I'm not sure if it would be helpful. Note that in the case of media not found, the HTTP code is 400.

I think that is the best way to register the HTTP status code in the WhatsappApiError and expose it with public int getHttpStatusCode().

I hope that is useful 😀.

Thanks,
Giuseppe.

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

2 participants