title: Uncaught ReferenceError: errorHandler is not defined at file
body: <p>i'm getting the error : Uncaught ReferenceError: errorHandler is not defined at file:</p>
  
  <p>what am i doing wrong? source code: <a href="http://pastebin.com/3203ynUB" rel="nofollow">http://pastebin.com/3203ynUB</a> 
  i iniate the first piece with onclick="startBackup()"</p>
  
  <p>it seems to go wrong somewhere in retrieving data from the database, but i cant figure out how and where.</p>
  
  <p>the database is as following</p>
  
  <p>DBName: SmartPassDB</p>
  
  <p>Table name: SmartPass</p>
  
  <p>rows: id , name , nickName , passID , Website</p>
  
  <pre><code>// change to your database
  var db = window.openDatabase("Database", "1.0", "SmartPassDB", 5*1024); // 5*1024 is size in bytes
  
  // file fail function
  function failFile(error) {
   console.log("PhoneGap Plugin: FileSystem: Message: file does not exists, isn't writeable or isn't readable. Error code: " + error.code);
   alert('No backup is found, or backup is corrupt.');
  }
  
  // start backup (trigger this function with a button or a page load or something)
  function startBackup() {
   navigator.notification.confirm('Do you want to start the backup? This will wipe your current backup. This action cannot be undone.', onConfirmBackup, 'Backup', 'Start,Cancel');
  }
  
  // backup confirmed
  function onConfirmBackup(button) {
   if(button==1) {
    backupContent();
   }
  }
  
  // backup content
  function backupContent() {
   db.transaction(
    function(transaction) {
     transaction.executeSql(
      // change this according to your table name
      'SELECT * FROM SmartPass;', null,
      function (transaction, result) {
       if (result.rows.length &gt; 0) {
        var tag = '{"items":[';
        for (var i=0; i &lt; result.rows.length; i++) {
         var row = result.rows.item(i);
         // expand and change this according to your table attributes
         tag = tag + '{"id":"' + row.attribute1 + '","name":"' + row.attribute2 + '","nickName":"' + row.attribute3 + '","passId":"' + row.attribute4 + '","website":"' + row.attribute5 + '"}';
         if (i+1 &lt; result.rows.length) {
          tag = tag + ',';
  
         }
        }
        tag = tag + ']}';
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
         // Change the place where your backup will be written
         fileSystem.root.getFile("backup.txt", {create: true, exclusive: false}, function(fileEntry) {
          fileEntry.createWriter(function(writer) {
           writer.write(tag);
          }, failFile);
         }, failFile);
        }, failFile);
     alert("Backup done.");
       } else {
        alert("No content to backup.");
       }
      },
      errorHandler
     );
    }
   );
  }
  
  // start restore (trigger this function with a button or a page load or something)
  function startRestore() {
   navigator.notification.confirm('Do you want to start the restore? This will wipe your current data. This action cannot be undone.', onConfirmRestore, 'Restore', 'Start,Cancel');
  }
  
  // restore confirmed
  function onConfirmRestore(button) {
   if(button==1) {
    restoreContent();
   }
  }
  
  // restore content
  function restoreContent() {
   db.transaction(
    function(transaction) {
     transaction.executeSql(
      // change this according to your table name
     'DELETE FROM SmartPass', startRestoreContent()
    );
   });
  }
  
  // actually start restore content
  function startRestoreContent() {
   window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
    // Change the place where your backup is placed
    fileSystem.root.getFile("backup.txt", null, function(fileEntry) {
     fileEntry.file(function(file) {
      var reader = new FileReader();
      reader.onloadend = function(evt) {
       var data = JSON.parse(evt.target.result);
       var items = data.items;
       count = items.length;
       db.transaction(
        function(transaction) {
         $.each(items, function(index, item) {
          transaction.executeSql(
          // change and expand this according to your table name and attributes
          'INSERT INTO SmartPass (id, name, nickName, passId, website) VALUES (?, ?, ?, ?, ?)',
          [item.attribute1, item.attribute2, item.attribute3, item.attribute4, item.attribute5],
          null
         );
        });
       });
      };
      reader.readAsText(file);
      alert("Restore done.");
     }, failFile);
    }, failFile);
   }, failFile);
  }
  </code></pre>