2

I'm investigating a crash in my Ruby application. The stack trace in my log isn't enough information, and I cannot reproduce the error. When an unhandled exception occurs, I need to log the values of the locals in the frame where the exception occurred.

Is there any way to do that in Ruby?

sawa
  • 165,429
  • 45
  • 277
  • 381
Hubro
  • 56,214
  • 69
  • 228
  • 381
  • Your not being able to reproduce the error and your implication that you have access to (i.e., can reproduce) the stack trace seems contradictory. – sawa Feb 10 '16 at 08:51
  • @sawa I got the stack trace from the server log. I am unable to reproduce the error because it's not happening, and as far as I can tell it **can't** happen. I have absolutely no idea how the error occurred. When/if the error occurs in production again, I still won't be able to fix it unless I have more information. – Hubro Feb 10 '16 at 09:12

1 Answers1

2

It is not easy to do it yourself, but there is a gem binding_of_caller (gem) written by banisterfiend that makes it possible.

sawa
  • 165,429
  • 45
  • 277
  • 381
  • 1
    I'll take your answer to mean that it can't be done without black magic that has no place in a production environment... I'll just add some print calls to the location where the crash happens and hopefully it'll be enough information the next time it crashes. – Hubro Feb 10 '16 at 09:55