Skip to content

JSON::ParserError #77

Description

@fmasuhr

Sometimes the flickr api returns html with status 502 and in that case I get an JSON::ParserError

JSON::ParserError: 795: unexpected token at '<!DOCTYPE html> <html lang="en-us"><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <title>Yahoo</title> <meta name="viewport" content="width=device-width,initial-scale=1,minimal-ui"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <style> html { height: 100%; } body { background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%; background-size: cover; height: 100%; text-align: center; font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif; } table { height: 100%; width: 100%; table-layout: fixed; border-collapse: collapse; ...nt-weight: 400; color: #400090; } p { color: #1A1A1A; } #message-1 { font-weight: bold; margin: 0; } #message-2 { display: inline-block; *display: inline; zoom: 1; max-width: 17em; _width: 17em; } </style> </head> <body> <!-- status code : 502 --> <!-- Server Connection Closed rw.api.flickr.com --> <!-- host machine: r24.ycpi.bf1.yahoo.net --> <table> <tbody><tr> <td> <img src="https://s.yimg.com/nn/img/yahoo-logo-201402200629.png" alt="Yahoo Logo"> <h1 style="margin-top:20px;">Will be right back...</h1> <p id="message-1">Thank you for your patience.</p> <p id="message-2">Our engineers are working quickly to resolve the issue.</p> </td> </tr> </tbody></table> </body></html> '

Here is the stack trace

/gems/json-1.8.1/lib/json/common.rb:155 in "parse"
/gems/json-1.8.1/lib/json/common.rb:155 in "parse"
/gems/json-1.8.1/lib/json/common.rb:334 in "load"
/gems/flickraw-0.9.8/lib/flickraw/api.rb:131 in "process_response"
/gems/flickraw-0.9.8/lib/flickraw/api.rb:59 in "call"

The problem is that it checks for XML only or else it will parse it as JSON

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions