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

error responses without detailed information #251

Open
SHoogland opened this issue Oct 30, 2019 · 1 comment
Open

error responses without detailed information #251

SHoogland opened this issue Oct 30, 2019 · 1 comment

Comments

@SHoogland
Copy link

  1. What version of the module is the issue happening on? Does the issue happen on latest version?
    0.22.0
  2. What platform and Node.js version? (For example Node.js 6.9.1 on Mac OS X)
    node js 12 netlify functions
  3. Does the action work when you manually perform request against mailgun using curl (or other means)?
    Thats the thing, let me explain in the description
  4. Sample source code or steps to reproduce
  • use mailgun.messages().send() with a delivery time further than 3 days ahead of time
  • response code/response from mailgun will be (as told by their support) Specific delivery time must not be farther than 3 days from now
  • response code from this library (the send function error callback): {"statusCode":400}

(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)
So the issue is that some of mailguns helpful response error message gets lost through this library.
I read the package is no longer maintained, so this is just a note for myself and maybe others who find it useful

@pfiadDi
Copy link

pfiadDi commented Nov 14, 2019

I saw your posting while I was going to write about a similar issue and with your posting I solved it.
I think the documentation or callback naming is misleading.
The error contains the status code (as you said) but the body still exists.
So I use something like:

if(error) {
        reject(JSON.stringify(body));
      } else {
        resolve(body);
      }

I had the problem in a different direction, I checked first for if(body) and found it strange that I get an error from mailgun but no error.
Yeah because body exists always (and contains the propper API feedback) and error only if there was an error. So if you want to use the error message you have to parse the body if the error object exists

hth

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

No branches or pull requests

2 participants