NH Prof New FeatureError Detection

time to read 2 min | 392 words

The feature for the day is detecting & notifying the user about NHibernate errors, warning messages and other things that require human attention. As a simple example, let us take this common error:

public class ErrorSavingToDatabase : IScenario
{
    public void Execute(ISessionFactory factory)
    {
        using(var s = factory.OpenSession())
        using(var tx = s.BeginTransaction())
        {
            s.Save(new Blog
            {
                Title = "Will error",
                CreatedAt = DateTime.MinValue// cause error
            });

            tx.Commit();
        }
    }
}

Which will give us:

image 

There are quire a few things going on in here.

First, we can see that NH Prof correctly detected the statement that caused an error and marked it as failed. We can also see the next statement, which give us the actual error details about the actual issue. This means that we have direct access to everything, and can usually understand what is going on very easily, by seeing both the error and the statement that caused it.

This isn’t actually limited to issues that are being raised from exceptions executing SQL queries, there are several cases where NHibernate itself needs to let you know about an issue. In those cases, the profiler will detect and display the message and expose it to you in a visible manner.

More posts in "NH Prof New Feature" series:

  1. (09 Dec 2010) Alert on bad ‘like’ query
  2. (10 Dec 2009) Filter static files
  3. (16 Nov 2009) Exporting Reports
  4. (08 Oct 2009) NHibernate Search Integration
  5. (19 Aug 2009) Multiple Session Factory Support
  6. (07 Aug 2009) Diffing Sessions
  7. (06 Aug 2009) Capturing DDL
  8. (05 Aug 2009) Detect Cross Thread Session Usage
  9. (22 May 2009) Detecting 2nd cache collection loads
  10. (15 May 2009) Error Detection
  11. (12 May 2009) Queries by Url
  12. (04 Feb 2009) View Query Results
  13. (18 Jan 2009) Superfluous <many-to-one> update
  14. (18 Jan 2009) URL tracking
  15. (10 Jan 2009) Detecting distributed transactions (System.Transactions)
  16. (06 Jan 2009) The Query Cache
  17. (05 Jan 2009) Query Duration
  18. (24 Dec 2008) Unbounded result sets
  19. (24 Dec 2008) Row Counts