better error handling

This commit is contained in:
AJ ONeal 2018-01-29 15:01:10 -07:00
parent 9dfa8ed323
commit f479c55501
2 changed files with 13 additions and 10 deletions

View File

@ -277,6 +277,10 @@ module.exports.create = function (cli, engine/*, dnsd*/) {
res.send({ error: { message: err.message } }); res.send({ error: { message: err.message } });
return; return;
} }
if (!record) {
res.send({ error: { message: "no record with id '" + id + "' found" } });
return;
}
if ('SOA' === record.type) { if ('SOA' === record.type) {
// TODO be strict about what can be edited // TODO be strict about what can be edited

View File

@ -397,16 +397,6 @@
var id = $qs('.js-record-id', $pel).value; var id = $qs('.js-record-id', $pel).value;
var existingRecord = cache.recordsMap[id]; var existingRecord = cache.recordsMap[id];
delete cache.recordsMap[id];
cache.records.some(function (r, i) {
if (r === existingRecord) {
cache.records.splice(i, 1);
return true;
}
});
renderRecords();
return window.fetch( return window.fetch(
'/api/records/' + id '/api/records/' + id
, { method: 'DELETE' , { method: 'DELETE'
@ -422,6 +412,15 @@
window.alert(data.error.message); window.alert(data.error.message);
return; return;
} }
delete cache.recordsMap[id];
cache.records.some(function (r, i) {
if (r === existingRecord) {
cache.records.splice(i, 1);
return true;
}
});
renderRecords();
console.log('result:', data); console.log('result:', data);
}); });
}); });