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

Better exception message from ApiException #39

Open
finci-square opened this issue Jan 25, 2021 · 11 comments
Open

Better exception message from ApiException #39

finci-square opened this issue Jan 25, 2021 · 11 comments
Labels
enhancement New feature or request

Comments

@finci-square
Copy link

finci-square commented Jan 25, 2021

Non successful http responses yield an ApiException whose message is just "HTTP Response Not OK". This is very cryptic and quite frustrating if the developer hasn't written code to capture more information about the error. It would be much improved if we parse the error response body and give an exception message that includes details from the response.

@sseaman
Copy link

sseaman commented Feb 2, 2021

Thanks for reporting this. We're investigating ways to improve it.

@finci-square
Copy link
Author

Ultimately all "Default*Api" classes call https://github.com/square/square-java-sdk/blob/65a992f0355ee404655170e00022cda2c71df01a/src/main/java/com/squareup/square/api/BaseApi.java validateResponse which news ApiException. The implementation of ApiException just needs to use the response if it has one and parse it earlier to pass to super

@wolfadex wolfadex added the enhancement New feature or request label Jan 10, 2022
@BryceBlankinship
Copy link

any progress on this one? I keep running into unexplainable "HTTP Response Not OK" errors and I am just guessing as to what I need to fix. One of my http responses worked too... not sure why!

@BryceBlankinship
Copy link

@finci-square aha I found my issue and I think that'll find yours, make sure you are importing the right ApiException class! I was getting mine from a google package instead of squares, then following this documentation for error handling: https://developer.squareup.com/docs/sdks/java/using-java-sdk#handle-the-responses

@finci-square
Copy link
Author

finci-square commented Nov 11, 2023 via email

@AnkitPatel1404
Copy link

@BryceBlankinship @sseaman @finci-square I'm importing right class but still getting same error message. Any alternative solution can you suggest?

@zenmasterjobo
Copy link

@AnkitPatel1404

Which API are you calling that is returning this error?

@finci-square @BryceBlankinship I have notified our team that creates the SDKs about stripping away the error message. I will update when I have more information about the change. I have also asked that they consider changing the name of the class to prevent potential name conflicts.

@BryceBlankinship
Copy link

Awesome thanks

@AnkitPatel1404
Copy link

AnkitPatel1404 commented Dec 14, 2023

Thanks for the response @zenmasterjobo, I'm using this API "paymentsApi.createPayment(body)"; and getting error message "HTTP Response Not OK".

@zenmasterjobo
Copy link

zenmasterjobo commented Dec 14, 2023

Thanks for the response @zenmasterjobo, I'm using this API "paymentsApi.createPayment(body)"; and getting error message "HTTP Response Not OK".

Hi @AnkitPatel1404 - if you can log into your developer dashboard and then click into your app, and then click API Logs in the left side navigation, you will be able to see some more details about the request your Java app made to Square. There should be a more clear error message logged there.

@AnkitPatel1404
Copy link

@zenmasterjobo @finci-square, In square dashboard, I got response like this "errors": [
{
"code": "GENERIC_DECLINE",
"detail": "Authorization error: 'GENERIC_DECLINE'",
"category": "PAYMENT_METHOD_ERROR"
}

Unable to find exact cause of this error. Can you please help me on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants