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

    committed
  2. Merge pull request #2 from bmoeskau/master

    committed
    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>
        <html>
        <head>
          <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; }
          </style>
        <title>Application Error</title>
        </head>
        <body>
          <iframe src="//s3.amazonaws.com/heroku_pages/error.html">
            <p>Application Error</p>
          </iframe>
        </body>
        </html>
    
    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

    committed
  2. Docs update

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

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

    committed
  2. Version bump

    committed
  3. Documentation fix

    committed
Commits on Oct 22, 2012
  1. Updating package name

    committed
  2. Indentation fix

    committed
  3. Updated License and Credits

    committed
  4. Implemented option aliases

    committed
  5. Documentation udpate

    committed
  6. Initial version

    committed
  7. Initial commit

    committed
Something went wrong with that request. Please try again.