Domanda

sto usando node.js e il "meno" compilatore middleware:

app.configure(function() {
    // ...
    app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }))
    // ...
})

Ora ho un .less file difettoso, ma non riesco a trovare nessuna documentazione su come ottenere il messaggio di errore. La pagina che ricevo è questo:

<html>
  <head>
    <title>[object Object]</title>
    <style>
      /* css stuff */
    </style>
  </head>
  <body>
    <div id="wrapper">
      <h1>Connect</h1>

      <h2><em>500</em> [object Object]</h2>
      <ul id="stacktrace"></ul>
    </div>
  </body>
</html>

In modo che non è utile. Qualcuno ha un'idea?

È stato utile?

Soluzione

Ah, ok, capito. Il trucco è quello di lasciare via allo sviluppo errorHandler

app.configure('development', function() {
    // app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

E sembra inghiottire le chiamate verso app.error, così ora funziona:

app.error(function(err, req, res, next) {
    sys.puts("APP.ERROR:" + sys.inspect(err));
    next(err);
});

Questo mostra il corretto errore anziché [object Object]

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top