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

[2.x] Add the ability to get the paddle error #248

Merged
merged 2 commits into from
Feb 27, 2024
Merged

[2.x] Add the ability to get the paddle error #248

merged 2 commits into from
Feb 27, 2024

Conversation

bensherred
Copy link
Contributor

@bensherred bensherred commented Feb 27, 2024

The aim of this pull request to make it easier to get the paddle error response. The Cashier currently throws an exception when Paddle returns an error, but it only provides the error.detail.

There is also a $message variable which is set but never used. I've therefore updated the PaddleException to use that custom $message variable and added a method for getting the Paddle error response.

One of the main use cases behind this PR, is being able to get the validation messages and formatting them into a readable format for the user.

@driesvints
Copy link
Member

Heya, thanks for your PR. Could you show a before/after example of this? Maybe through a screenshot of the Ignition error page?

@driesvints driesvints changed the title feat: add the ability to get the paddle error [2.x] Add the ability to get the paddle error Feb 27, 2024
@bensherred
Copy link
Contributor Author

Yeah sure thing

Before

A general exception with an invalid key:

image

An exception due to validation:

image

After

A general exception with an invalid key:

image

An exception due to validation:

image

By catching the exception and calling ->getError(), we can get the error response from Paddle like so:

image image

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@taylorotwell taylorotwell merged commit 20a78dc into laravel:2.x Feb 27, 2024
2 of 7 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants