Catching 500 internal server errors on Query send

102 views
Skip to first unread message

lesfreeman

unread,
Jun 24, 2010, 12:13:13 AM6/24/10
to Google Visualization API
Hello,
I'm trying to catch server errors and display a custom error message.
Unfortunetly, I can't seem to catch the error on the JS side. Here's
the short version of my code:

try{
var query = new google.visualization.Query("http://some-server.com/
api");
query.send(function(response){
//some stuff gets done here
});
}catch(e){
console.log(e.name+" "+e.message);
}

Unfortunately, the error does not get caught. I my JS console I get:

Uncaught Error: google.visualization.Query: Internal Server Error
[500]

If I throw a custom error in the try block, it gets caught.

Any ideas?

Thanks
Les

Jinji

unread,
Jun 27, 2010, 9:33:04 AM6/27/10
to google-visua...@googlegroups.com
The query.send() function doesn't throw exceptions. Instead, in your response function (the one you pass to query.send), you should do:

if (response.isError()) {
  alert(response.getMessage());
  return;
}
dataTable = response.getDataTable();

I hope that helps.



--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


lesfreeman

unread,
Jul 10, 2010, 8:22:26 PM7/10/10
to Google Visualization API
I've tried that method as well:

var query = new google.visualization.Query("http://some-server.com/
api");
console.log("about to send query");
query.send(function(response){
console.log("in response function");
if (response.isError()) {
alert(response.getMessage());
return;
}
var data = response.getDataTable();
...
});

The "about to send query" message is logged to the console but the "in
response function is not. Instead, I still get the Uncaught Error
message:

about to send query
Uncaught Error: google.visualization.Query: Internal Server Error
[500] -
default,browserchart,columnchart,barchart,piechart,table,gauge,annotatedtimeline
+en_US.I.js:151

Same thing if I move the console.log to after the if statement:

query.send(function(response){
if (response.isError()) {
alert(response.getMessage());
return;
}
console.log("in response function");
var data = response.getDataTable();
...
});

Really appreciate your time and your help!
Les


On Jun 27, 6:33 am, Jinji <ji...@google.com> wrote:
> The query.send() function doesn't throw exceptions. Instead, in your
> response function (the one you pass to query.send), you should do:
>
> if (response.isError()) {
>   alert(response.getMessage());
>   return;}
>
> dataTable = response.getDataTable();
>
> I hope that helps.
>
> > google-visualizati...@googlegroups.com<google-visualization- api%2Bunsu...@googlegroups.com>
> > .

ChartMan

unread,
Jul 11, 2010, 10:11:28 AM7/11/10
to google-visua...@googlegroups.com
Trying looking at the network console and see what is the response coming back from your server, maybe its malformed.

ChartMan

To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.

h

unread,
Apr 30, 2012, 9:02:06 AM4/30/12
to google-visua...@googlegroups.com
Please note that the error mechanism is based on a server that is using the charts data source library and returning a valid JSON response (error or not).
If there is a communication error the JavaScript callback is not called. However, Query does have a timeout for each request and after 30 seconds you will see an error
"request timed out".

HTH
ChartMan


> > To unsubscribe from this group, send email to

> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-visualization-api?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visualization-api@googlegroups.com.
To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages