Skip to content

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

Merged
taylorotwell merged 2 commits intolaravel:2.xfrom
bensherred:get-paddle-exception-error
Feb 27, 2024
Merged

[2.x] Add the ability to get the paddle error#248
taylorotwell merged 2 commits intolaravel:2.xfrom
bensherred:get-paddle-exception-error

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
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.

3 participants