]> granicus.if.org Git - pdns/commitdiff
json get-zone: properly return error if zone doesn't exist
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Wed, 4 Sep 2013 09:05:41 +0000 (11:05 +0200)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Wed, 4 Sep 2013 09:06:22 +0000 (11:06 +0200)
pdns/ws.cc

index 9c9952c5294cffc07f135d71432bf94481d8be81..9ead254839100266f23e96e6d114d622e4924ede 100644 (file)
@@ -327,15 +327,16 @@ static string json_dispatch(const string& method, const string& post, varmap_t&
   else if(command=="get-zone") {
     UeberBackend B;
     SOAData sd;
-    sd.db= (DNSBackend*)-1;
+    sd.db = (DNSBackend*)-1;
     if(!B.getSOA(varmap["zone"], sd) || !sd.db) {
-      cerr<<"Could not find domain '"<<varmap["zone"]<<"'\n";
-      return "";
+      map<string, string> err;
+      err["error"] = "Could not find domain '"+varmap["zone"]+"'";
+      return returnJSONObject(err);
     }
     sd.db->list(varmap["zone"], sd.domain_id);
     DNSResourceRecord rr;
 
-    string ret ="[";
+    string ret = "[";
     map<string, string> object;
     bool first=1;
     while(sd.db->get(rr)) {