Giter Site home page Giter Site logo

Comments (6)

peterbe avatar peterbe commented on June 12, 2024

A nasty workaround would be:

.filter((filePath) => {
  try {
     ...whatever code you wanted to run...
  } catch (er) {
    // See bug https://github.com/thecodrr/fdir/issues/56
    console.error(er); 
    throw er;
  }
})

from fdir.

thecodrr avatar thecodrr commented on June 12, 2024

I am taking a look into this right now.

from fdir.

thecodrr avatar thecodrr commented on June 12, 2024

@peterbe have you tried this with .withErrors? fdir by default ignores all errors thrown during crawling. You can turn on errors with .withErrors to have them passed on to the caller. This will require you to handle (or ignore) IO errors as well.

from fdir.

peterbe avatar peterbe commented on June 12, 2024

@peterbe have you tried this with .withErrors? fdir by default ignores all errors thrown during crawling. You can turn on errors with .withErrors to have them passed on to the caller. This will require you to handle (or ignore) IO errors as well.

I failed to notice that was an option.
Perhaps it's too late now, but I wish it'd be the other way around. I.e. errors raised by default with an option to .suppressErrors(). If an expert user is perfectly aware of the options it doesn't matter, but newbies might miss it and then accidentally get super frustrated in debugging and doing their own try/catch to log the possible errors.

from fdir.

peterbe avatar peterbe commented on June 12, 2024

Perhaps remove the bug label and add a "annoying refactor request" :)

from fdir.

thecodrr avatar thecodrr commented on June 12, 2024

errors raised by default with an option to .suppressErrors()

That is actually how it was in previous versions. My reasoning for going the opposite way was that most of the times IO errors are pretty useless (like file not found etc.) during crawling. The downside of current approach is that it captures and ignores all errors including syntax errors (like you reported). Maybe it should only handle IO errors thrown by the fs module and rethrow all other exceptions?

from fdir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.