Chrome: imprime detalles de excepción en la consola
Frecuentes
Visto 10,345 veces
9
How do I print the stack trace of an Exception in the chrome devtools from my code?
He probado lo siguiente:
function doSomething() {
undefined(); // This throws an exception
}
try {
doSomething();
} catch (e) {
console.error("Exception thrown", e);
}
Pero esto produce el siguiente resultado:
Exception thrown TypeError {}
And if I expand the arrow next to it, it points me to the line where the console.error() call was made, so I don't get to see where the original error actually happened.
What would be the best way to include the original error information (including message and complete stack trace to the exact location where the error happened) in the console output?
2 Respuestas
9
Objeto Error tiene una propiedad stack
. Print it out.
console.error("Exception thrown", e.stack);
este producto está hecho por encargo con un tiempo de producción de XNUMX a XNUMX semanas stack
property is not standardized and it is only used by V8 based browsers + IE. Firefox uses different convention.
Respondido el 26 de Septiembre de 13 a las 19:09
6
Respondido 25 Jul 18, 13:07
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas javascript google-chrome google-chrome-devtools or haz tu propia pregunta.
It seems that Firefox now uses
stack
también: stackoverflow.com/questions/147891/… - Nacho coloma