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

Allow to retrieve last error #11

Merged
merged 1 commit into from
May 10, 2022
Merged

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented May 10, 2022

Currently when using oneup/mailchimp-api-v3 it is not really possible to receive detailed error messages from Mailmhimp. For example, if you use the subscribeToList method, Mailmhimp might response with something like this in its response:

{
  "type": "https://mailchimp.com/developer/marketing/docs/errors/",
  "title": "Invalid Resource",
  "status": 400,
  "detail": "Your merge fields were invalid.",
  "instance": "8cf2c011-a212-9b3a-6c51-a4d631a124b4",
  "errors": [
    {
      "field": "VORNAME",
      "message": "Please enter a value"
    },
    {
      "field": "NACHNAME",
      "message": "Please enter a value"
    }
  ]
}

i.e. telling you that the merge fields you submitted are wrong and which ones and why.

This PR would always save the JSON encoded body of the non-200 responses as the last error so that you can retrieve it from the outside.

Copy link
Member

@bytehead bytehead left a comment

Choose a reason for hiding this comment

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

I like!

@bytehead bytehead merged commit 71d6113 into 1up-lab:master May 10, 2022
@bytehead
Copy link
Member

There you go: 2.4.0

@fritzmg fritzmg deleted the retrieve-last-error branch May 10, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants