Extending error object in express, but Debug does only show the stack trace

Abierto
#711 5 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
32/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
express, javascript, node.js
Área
backend, devtools

Línea de trabajo

Reproduce the Express error-handling middleware shown in the issue, comparing console.log(error) with debug output. Read the debug package's error-formatting behavior and verify whether the object properties are intentionally omitted; done means the behavior is fixed or clearly documented with a supported way to display the full error object.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Hello,

Small question of which I don't know it's a bug or expected behaviour:

In my express application I have the following app.use at the bottom:

app.use( (error, req, res, next) => {
    const status = error.statusCode || 500;
    const source = error.source || 'Unknown';
    const message = error.message;
    const info = error.info || '';
    console.log(error); // For logging on the server
    res.status(status).json({
        status: status,
        source: source,
        message: message,
        info: info
    })
});

This shows me the stack trace and the error object (with source and info properties).

When I change the console.log to debug, it only shows the stack trace and not the error object.

Why is that? And how can I show the error object with the debug command also?

Lenguaje dominante
JavaScript
Estrellas
11.5k
Forks
992
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de debug-js/debug

Todos los issues de debug-js/debug

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.