Return a better error message when an API call is made to a nation, endpoint that does not exist

When making an API call to an invalid endpoint the response returns the HTML from a 404 page. A response body describing the issue (endpoint does not exist, nation does not exist) along with a 404 status would be preferred for debugging issues.

Example:


[17] pry(main)> NationBuilder::Client.new("foo", "bar").call(:donations, :index)
NationBuilder::ClientError: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>404 Error: The page you were looking for doesn't exist</title>
<style type="text/css">
body {
background: url(http://nationbuilder.s3.amazonaws.com/assets/404-grass.jpg) repeat top left;
color: #fff;
font-family: Lucida Grande, Lucida Sans Unicode, Garuda, sans-serif;
margin: 15px 0;
font-size: 1em;
}
#wrapper {
padding: 15px 0 0 45px;
}
#headline {
font-size: 2em;
font-weight: bold;
text-shadow: -1px -1px #333;
color: yellow;
}
#description {
font-size: 1.3em;
line-height: 1.8em;
color: #fff;
text-shadow: -1px -1px #333;
}
#footer {
clear: both;
font-size: 0.8em;
}
a:link, a:active, a:visited {
color: #ec7c31;
text-decoration: none;
}
a:hover {
text-decoration: none;
background-color: #fee34c;
color: #000;
}
#road {
margin-top: 15px;
}
</style>
</head>

<body>
<!-- This file lives in public/404.html -->

<div id="road">

<div id="wrapper">
<div id="headline">We couldn't find the page you were looking for.</div>
<div id="description">You may have mistyped the address or the page may have moved.</div>
</div>
<div id="road"><img src="http://nationbuilder.s3.amazonaws.com/assets/404-road.png" width="952" height="404"></div>
</div>

</body>
</html>
from [...]/gems/nationbuilder-rb-1.5.0/lib/nationbuilder/client.rb:129:in `parse_response_body'

Considering

Official response from

This is something we will consider but does not have a timeline at the moment.

Complete and current information on how to use NationBuilder is available in the documentation section.

Share this post

Showing 1 reaction

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.