Are errors thrown by the fs library catchable?

Posted on
  • I've got the following code running, deliberately without having an SD card in the slot, but the catch statement never seems to execute. Am I being stupid?

    I see ERROR: Unable to mount media : NOT_READY on the console but not caught an error. If I remove all my console.log, I still get ERROR: Unable to mount media : NOT_READY so I'm assuming it is being logged higher up the stack?

    SPI1.setup({ mosi: A7, miso: A6, sck: A5 });
    E.connectSDCard(SPI1, B1);
    
    var fs = require("fs");
    
    try {
      fs.readdirSync();
    } catch (err) {
      console.log('caught an error');
      console.log(err);
    }
    
  • That's a really good point - no, they're not.

    I've just filed a bug for it, and I'll try and get it fixed for the next release: https://github.com/espruino/Espruino/iss­ues/1164

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Are errors thrown by the fs library catchable?

Posted by Avatar for dave_irvine @dave_irvine

Actions