Finding Hidden Exceptions in Your Application with Prefix

By: mwatson
  |  August 17, 2023
Finding Hidden Exceptions in Your Application with Prefix

Prefix enables developers to easily see what their code is doing as they write and test their code, including SQL queries, HTTP calls, errors, logs, and much more. One of the best features of Prefix is its ability to see all of the exceptions that are occurring in your code.

There are 3 types of exceptions:

  1. Unhandled – the user got a 500 error and your app blew up 🙁
  2. Logged – your code “caught” the error and logged it somewhere
  3. Hidden – your code “caught” the error and it is never logged

Please note that, depending on if you are using .NET or Java, the functionality and potential configuration needed for errors and logs could be slightly different.

View Unhandled Exceptions with Prefix

Prefix will automatically show you all exceptions from a web request that abruptly ends in an exception. In this example below you can see the full stack trace and that the request ended with a 500 error.

500-error

View Logged Exceptions with Prefix

If you are using Java, Prefix will automatically show any exception that is logged to log4j or logback. For .NET, you will need to follow the directions in our docs to add the Stackify log appender to your app for log4net, Serilog, or NLog.

We highly recommend always using a common logging framework for your errors and logs. This abstracts away how you do logger from any single implementation and makes it easy to direct your log data to various targets like a file on disk or log management product like Retrace.

Viewing Hidden Exceptions with Prefix

For .NET only, Prefix is able to collect every exception that is ever thrown. In .NET these are sometimes called first chance exceptions. These are the types of exceptions that are sometimes caught deep within code bases and thrown away.

A good example of a hidden exception is this error from nopCommerce, which is a popular open source .NET ecommerce engine. It throws an exception on every page load trying to convert a value to an integer, something easily avoided with a int.TryParse().

nopcommerce-error2

Get the Whole Story with Errors & Logs Combined

One of the coolest features about Prefix and Retrace both is the ability to see all of your logs (and errors) for a single web request together. Logs combined with SQL queries, HTTP calls, and many other common dependencies, makes understanding what your code is doing much easier.

Example showing debug logging, exception, 2 SQL queries, and a redis call.

prefix-error-log-full-trace-2

 

Prefix is free. Download it today and get started with your bug hunt!

If an exception happens and there is no code there to catch it, does it still bug you? #nerdHumor

 

Get Prefix Power on a server!
Get Prefix Power on a server!


Improve Your Code with Retrace APM

Stackify's APM tools are used by thousands of .NET, Java, PHP, Node.js, Python, & Ruby developers all over the world.
Explore Retrace's product features to learn more.

Learn More

Want to contribute to the Stackify blog?

If you would like to be a guest contributor to the Stackify blog please reach out to [email protected]