-
Notifications
You must be signed in to change notification settings - Fork 112
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
feat(api): Introduce new error #3215
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ def generate_checkout_url(send_webhook: true) | |
result | ||
rescue ::Stripe::InvalidRequestError, ::Stripe::PermissionError => e | ||
deliver_error_webhook(e) | ||
result | ||
fail! e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oups... Indeed, this one in this scope should not be swallowed... 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fix this separately so we can get it fixed today |
||
rescue ::Stripe::AuthenticationError => e | ||
deliver_error_webhook(e) | ||
|
||
|
@@ -203,6 +203,21 @@ def deliver_error_webhook(stripe_error) | |
) | ||
end | ||
|
||
def fail!(stripe_error) | ||
result.fail_with_error!(PaymentProviderFailure.new( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep the "easy" way, you could rely on |
||
result, | ||
message: stripe_error.message, | ||
status: stripe_error.http_status, | ||
payment_provider: stripe_payment_provider.name, | ||
payment_provider_code: stripe_payment_provider.code, | ||
details: { | ||
request_id: stripe_error.request_id, | ||
code: stripe_error.code, | ||
error: stripe_error.error | ||
} | ||
)) | ||
end | ||
|
||
def handle_missing_customer(organization_id, metadata) | ||
# NOTE: Stripe customer was not created from lago | ||
return result unless metadata&.key?(:lago_customer_id) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are relying on many integration, I would suggest to rename the
ThirdPartyFailure
intoIntegrationFailure
and allow it to expose the initial error from the provider.In many places in the project we have different ways of dealing with provider error, I'm not sure that adding a new one will simplify it 😄