Skip to content
Commits on Jun 27, 2014
  1. v1.0.3

  2. Merge pull request #2 from bmoeskau/master

    Better Premailer server error handling
Commits on Jun 26, 2014
  1. @bmoeskau

    Better Premailer server error handling

    bmoeskau committed
    I've found that lately the Premailer server has been failing inconsistently, and the error message I was getting back from premailer-api was `SyntaxError: Unexpected token <` along with a stack trace. This was causing me to think I was passing invalid HTML as input. After debugging, I found out that in fact, this error is due to premailer-api's current error handling assuming the response is valid JSON.  In fact, (unfortunately) the response I'm getting from Premailer looks like this currently:
        <!DOCTYPE html>
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <style type="text/css">
            html, body, iframe { margin: 0; padding: 0; height: 100%; }
            iframe { display: block; width: 100%; border: none; }
        <title>Application Error</title>
          <iframe src="//">
            <p>Application Error</p>
    That is the `body` value being passed to `JSON.parse`, hence the unexpected token error. Obviously the error coming back from Premailer itself appears to be due to bad handling on their side, but I guess trying to deal with it in a sensible way is at least better than raising it as a misleading error from premailer-api.
    The suggested patch is ugly, but at least allows for clean reporting of what's going on to the end user of the lib.  Now, how to go about fixing the Premailer server....
Commits on Sep 23, 2013
  1. v1.0.2

  2. Docs update

  3. Merge pull request #1 from jbuck/parse-error

    Fix crash when JSON response fails to parse
  4. @jbuck
Commits on Oct 23, 2012
  1. Spelling fix

  2. Version bump

  3. Documentation fix

Commits on Oct 22, 2012
  1. Updating package name

  2. Indentation fix

  3. Updated License and Credits

  4. Implemented option aliases

  5. Documentation udpate

  6. Initial version

  7. Initial commit

Something went wrong with that request. Please try again.