better error handling
This commit is contained in:
		
							parent
							
								
									9dfa8ed323
								
							
						
					
					
						commit
						f479c55501
					
				@ -277,6 +277,10 @@ module.exports.create = function (cli, engine/*, dnsd*/) {
 | 
			
		||||
          res.send({ error: { message: err.message } });
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
        if (!record) {
 | 
			
		||||
          res.send({ error: { message: "no record with id '" + id + "' found" } });
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ('SOA' === record.type) {
 | 
			
		||||
          // TODO be strict about what can be edited
 | 
			
		||||
 | 
			
		||||
@ -397,16 +397,6 @@
 | 
			
		||||
    var id = $qs('.js-record-id', $pel).value;
 | 
			
		||||
    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(
 | 
			
		||||
      '/api/records/' + id
 | 
			
		||||
    , { method: 'DELETE'
 | 
			
		||||
@ -422,6 +412,15 @@
 | 
			
		||||
          window.alert(data.error.message);
 | 
			
		||||
          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);
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user