-
Notifications
You must be signed in to change notification settings - Fork 37
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
HttpException's message does not return a proper PayoutError POJO #14
Comments
@hadjiski paypalhttp allows only a success type to be deserialised, for errors the Encoder from the paypalhttp can be used to deserialise the error type.
will update samples and readme to reflect the same |
@rajkumarpalani thank you for sharing this possible solution. From it I derive that the The current workaround solution from above, which I am currently using is a bit more elegant I would say: |
@hadjiski updated comment to reflect that Created an issue on paypalhttp, will try to raise a PR to address the same - paypal/paypalhttp_java#5 |
@rajkumarpalani currently both are identical from content perspective, but good to know for the future. |
@hadjiski Yes, both Going to cleanup the error classes and will provide a much simpler version. The current |
@hadjiski Payouts SDK v1.1.0 released with most of the errors cleaned up. Check out the changelog - https://github.com/paypal/Payouts-Java-SDK/blob/master/CHANGELOG.md |
@rajkumarpalani thanks a lot for the quick release, btw. do you still plan to further simplify the error handling skipping the explicit de-serialization part or is this kind of the final solution now? |
@hadjiski I started working on a PR to get typed entity out of HttpException and realised that exceptions cannot be generic in Java. This restricts the possibility of getting a typed entity out of the HttpException as expected out of the issue paypal/paypalhttp_java#5 The options are to emit exception as a return type such as,
This allows the client to populate the entity as per the result, but this involves huge changes for existing integrations and also doesn't align with the current pattern that paypalhttp library adopts across all supported languages. The problem seems to be specific on strongly typed languages like Java. Am hoping to catch up with the paypalhttp team and bring up the issue and update here on the proceedings. |
I see the API deserializes json strings into POJOs (e.g
CreatePayoutResponse
) using a customcom.paypal.http.annotations.SerializedName
annotation and simple java reflections technique.OK, but then could you also make the thrown
com.paypal.http.exceptions.HttpException
also return a deserialized POJO, when.getMessage()
is called, because an auto deserialization via Jackson for example is not working, since POJO field names and serialized json string key names are not matching to each other - ok it is possible indirectly by extendingPayoutError
andPayoutErrorDetails
and annotating the fields with the Json deserialization library of choice, but not so nice:So it looks like the suitable POJO is the
com.paypal.payouts.PayoutError
These type of messages of
HttpException
I saw till now and they seem to fit exactly thePayoutError
POJO:The text was updated successfully, but these errors were encountered: