Code Monkey home page Code Monkey logo

Comments (5)

tj avatar tj commented on March 28, 2024

how about we remove app.outputErrors (and just imply that stuff in the default handler), and make it app.error(fn) so that you can easily override it without manually removing one or all or some of the listeners, but at least then it's still "batteries included"

from koa.

jonathanong avatar jonathanong commented on March 28, 2024

something like:

function App() {
  this.on('error', logger);
}

App.prototype.error = function(fn){
  this.removeListener('error', logger);
  this.on('error', fn);
}

function logger(err) {
  if ('test' != this.env) console.error(err.stack);
}

i think that'll work. remember, no .bind(this) necessary in node! haha

from koa.

tj avatar tj commented on March 28, 2024

yeah I think that'll work pretty good, and we can forward mounted app errors upstream

from koa.

tj avatar tj commented on March 28, 2024

think im fine with this for now actually, it's easier to explain app.outputErrors = false than if you call app.error() it overrides it, and you can add additional listeners with "error" etc blha blah. Plus IMHO you always want stderr traces, never know when other forms of reporting may fail

from koa.

jonathanong avatar jonathanong commented on March 28, 2024

haha, so i thought about errors where you don't want them to be logged, but then i realized how much easier error handling will be vs express

from koa.

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.