¿Cómo sé qué errores se están arrojando en mis bloques try-catch?

When I'm building my programs, I have a number of try-catch blocks and when they throw errors, I seem to have trouble seeing what caused the error - I've tried looking at the stack-trace but I always end up commenting out the error handling and re-running.

Is there a better way? (I'm sure there must be ...)

If every time I have to comment out the bits of my try-catch to figure out el porqué it was throwing it seems like I should be able to look at the stack-trace or something. Sorry if it's a simple question but it should have a simple answer ...

preguntado el 05 de mayo de 13 a las 12:05

Not sure why it was a bad question but I apologise none-the-less. -

Thanks for the support peoples! -

1 Respuestas

In Visual Studio, do the follow steps:

  • Menu [Debug]
  • Option [Exceptions...]
  • On the right of [Common Language Runtime Exceptions], check the box under [Thrown].

Now your application will always stop (as if it is a breakpoint) at the line where an exception is thrown.

contestado el 05 de mayo de 13 a las 12:05

Ahh, thanks ... that's perfect. Does exactly what I thought VS was supposed to do. Don't happen to know why I was down voted so rigorously do you? - Sísifo

Well... I think you are downvoted for simply not knowing how to read a stacktrace. I must agree: you must be able to. But this tric is just working much better. So... Do not worry about. Sometimes my answers, correct and all, are downvoted too. - Martín Mulder

Thanks - It's tough on here trying to ask good questions- especially when you are learning. Sometimes you just don't search for the right things ... - Sísifo

@Sisyphus: That is correct. Just do not loose your hope and just keep learning and asking questions! :) - Martín Mulder

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.