You can include a function like this:
function fileExists(url)
{
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status!=404;
}
And then modify your code like so:
var adm1_path = "../topo/"+d.id+"_adm1.json"
if (!fileExists(adm1_path)) {
alert('We couldn't find that country!') //or some other suitable error/display mechanism
return;
}
d3.json(adm1_path, function(error, topology) {