Sorry for the newbie question, but I've been banging my head against this for quite a while.
In the dummy code below, there are three functions - two that are "required" by the Visualization API and one RunMe() that kicks it off. If a spreadsheet request is invalid, I can access the error message it returns from the handleQueryResponse() function. But for my purposes, I need to be able to test for the existence of response.isError() from within the runMe() function. This seems simple, but I can't seem to get at that response object from outside of handleQueryResponse(). This may be due to my JavaScript newbie status or because the API does something weird.
I also find it weird that uncommenting console.log(query); in the getTableMeta() function produces an "Er" object that just seems to be a prototype, not a representation of the actual query.
Thanks for suggestions.
The spreadsheet ID below is invalid with the "z" at the end and valid with it removed.
function runMe() {
var foo = getTableMeta('0AtP_YtDJ532RdDcxZUl6Zkl4YkxKcEYzbld4ZDA4SlEz');
// console.log(response);
// console.log(response.getMessage());
// console.log(foo.getMessage());
}
// Get table metadata from Google
function getTableMeta(spreadsheet_id) {
// console.log(query);
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
// alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage() + '. Please click Previous and enter a different spreadsheet ID.');
console.log(response.getMessage());
}
return response;
}
runMe();