Sometimes we’re faced with bugs that just don’t make any sense. I think we’ve all said to ourselves after reading the offending function sources – “but this situation cannot happen in the code”, and yet the same annoying error keeps on occurring. For situations like this, when screenshot, error message + call stack aren’t enough and you cannot reproduce the error – then we would also like to know the input parameters to the function when it crashes. With RootCause, there is a special trick to gather this extra error context.

Capturing function arguments

Let’s say in our application we have a class responsible for serializing and deserializing data to/from JSON.

If there is a crash in the JSONUtil.decode method, it’s really hard to understand the true cause of the error without knowing the input data. Consider the malformed input data below:

If this code runs, you would see the image below in the RootCause Dashboard :

This error message doesn’t provide any clue whatsoever to where the error might be. The information we need to fix this issue is the input parameter of the method. To find out what it is, we first need to tell RootCause to load JS overrides at startup, with the enableArgumentsCapturing flag.

When this flag is set, the RootCause client will query the RC server for overrides for the current application. In our Dashboard application settings page, we can now go ahead and define an override to capture the arguments:

With this override in place, we just wait for the error to be triggered again. When the next error report shows up in the dashboard, you’ll have the additional context you need:

This gives us a vital piece of information, somewhere in the app there is some malformed JSON generated. Hopefully this clue helps you fix the bug, and when you’ve found the bug – you simply complete the debugging process by removing your override in the application settings page.

Please note, if you’re able to reproduce the error in your browser then you can of course inspect all the application context and function parameters ‘live’ and you don’t need the trick described in this post. Good luck fighting the tricky bugs out there!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">