Skip to content

Create universal error/exceptions classes for manual operations #10

Description

@Osiris-Team

For example when trying to cancel a subscription, the subscription might not exist anymore if its older, thus an HttpErrorException will be thrown with for example a message like "The specified resource does not exist." (Paypal) or "No such subscription" (Stripe).

Instead thrown specific exceptions so that the developer is forced to handle these cases.

PayPal:

[07-10-2024 06:40:33][AP-Web][WARN] ================================
[07-10-2024 06:40:33][AP-Web][WARN] Message: null
[07-10-2024 06:40:33][AP-Web][WARN] Details: 
url: https://api-m.paypal.com/v1/billing/subscriptions/I-xxxxxxxxxxxxx
code: 404 
message: 
json: 
{"name":"RESOURCE_NOT_FOUND","message":"The specified resource does not exist.","debug_id":"xxxxxxxxxxxxxx","details":[{"issue":"INVALID_RESOURCE_ID","description":"Requested resource ID was not found."}],"links":[{"href":"https://developer.paypal.com/docs/api/v1/billing/subscriptions#RESOURCE_NOT_FOUND","rel":"information_link","method":"GET"}]}
[07-10-2024 06:40:33][AP-Web][WARN] Type: com.osiris.jlib.json.exceptions.HttpErrorException
[07-10-2024 06:40:33][AP-Web][WARN] Stacktrace: 
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.payhook.paypal.UtilsPayPalJson.jsonFromUrl(UtilsPayPalJson.java:50)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.payhook.paypal.UtilsPayPalJson.getJsonElement(UtilsPayPalJson.java:87)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.payhook.paypal.PayPalUtils.getSubscriptionDetails(PayPalUtils.java:367)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.payhook.paypal.PayPalUtils.cancelSubscription(PayPalUtils.java:225)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.payhook.PayHook.cancelPayment(PayHook.java:1117)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.autoplug.webserver.GD.lambda$static$3(GD.java:191)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.jsqlgen.payhook.Product.lambda$onPaymentExpired$5(Product.java:727)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.events.Event.lambda$addAction$6(Event.java:144)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.events.Event.execute(Event.java:101)
[07-10-2024 06:40:33][AP-Web][WARN] com.osiris.payhook.PayHook.lambda$init$5(PayHook.java:271)
[07-10-2024 06:40:33][AP-Web][WARN] java.base/java.lang.Thread.run(Thread.java:1583)
[07-10-2024 06:40:33][AP-Web][WARN] ================================

Stripe:

[07-10-2024 05:40:32][AP-Web][WARN] ================================
[07-10-2024 05:40:32][AP-Web][WARN] Message: null
[07-10-2024 05:40:32][AP-Web][WARN] Details: No such subscription: 'sub_xxxxxxxxxxxxxx'; code: resource_missing; request-id: req_xxxxxxxxxxxxxxxxx
[07-10-2024 05:40:32][AP-Web][WARN] Type: com.stripe.exception.InvalidRequestException
[07-10-2024 05:40:32][AP-Web][WARN] Stacktrace: 
[07-10-2024 05:40:32][AP-Web][WARN] com.stripe.net.LiveStripeResponseGetter.handleApiError(LiveStripeResponseGetter.java:194)
[07-10-2024 05:40:32][AP-Web][WARN] com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:65)
[07-10-2024 05:40:32][AP-Web][WARN] com.stripe.net.ApiResource.request(ApiResource.java:181)
[07-10-2024 05:40:32][AP-Web][WARN] com.stripe.model.Subscription.cancel(Subscription.java:644)
[07-10-2024 05:40:32][AP-Web][WARN] com.stripe.model.Subscription.cancel(Subscription.java:596)
[07-10-2024 05:40:32][AP-Web][WARN] com.osiris.payhook.PayHook.cancelPayment(PayHook.java:1121)
[07-10-2024 05:40:32][AP-Web][WARN] com.osiris.autoplug.webserver.GD.lambda$static$3(GD.java:191)
[07-10-2024 05:40:32][AP-Web][WARN] com.osiris.jsqlgen.payhook.Product.lambda$onPaymentExpired$5(Product.java:727)
[07-10-2024 05:40:32][AP-Web][WARN] com.osiris.events.Event.lambda$addAction$6(Event.java:144)
[07-10-2024 05:40:32][AP-Web][WARN] com.osiris.events.Event.execute(Event.java:101)
[07-10-2024 05:40:32][AP-Web][WARN] com.osiris.payhook.PayHook.lambda$init$5(PayHook.java:271)
[07-10-2024 05:40:32][AP-Web][WARN] java.base/java.lang.Thread.run(Thread.java:1583)
[07-10-2024 05:40:32][AP-Web][WARN] ================================

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions