/// <summary>
            /// Creates a new object from the underlying failing query.
            /// </summary>
            /// <param name="underlyingFailingQuery">The underlying failing query dataset.</param>
            /// <param name="penaltyInfo">The penalty info.</param>
            /// <remarks>
            /// Yes, this is code duplication with RssiRestApiController and a common base-class would make sense design-wise (is-a FailingQuery).
            /// But this has been added later and the underlying classes are Entity Framework Database Models.
            /// I'm simply scared of modifying them to have a common base class. Not sure if EF migration framework is able to handle this.
            /// </remarks>
            public BgpFailingQueryWithPenaltyInfo(BgpFailingQuery underlyingFailingQuery, ISingleFailureInfo penaltyInfo)
            {
                if (underlyingFailingQuery == null)
                {
                    throw new ArgumentNullException(nameof(underlyingFailingQuery), "The underlying failing query data is null");
                }

                this.Host        = underlyingFailingQuery.Host;
                this.ErrorInfo   = underlyingFailingQuery.ErrorInfo;
                this.TimeStamp   = underlyingFailingQuery.TimeStamp;
                this.PenaltyInfo = underlyingFailingQuery.PenaltyInfo;

                if (penaltyInfo != null)
                {
                    // only replacing the object that has potentially been retrieved from database
                    // if we have a more recent one directly from handler.
                    if (this.PenaltyInfo == null)
                    {
                        // we have not penalty info -> unconditionally set the new one
                        this.PenaltyInfo = penaltyInfo;
                    }
                    else if (this.PenaltyInfo.LastOccurance <= penaltyInfo.LastOccurance)
                    {
                        // we have a penalty info -> only set if new one is newer or same
                        this.PenaltyInfo = penaltyInfo;
                    }
                }
            }
        /// <summary>
        /// Records a failing query.
        /// </summary>
        /// <param name="databaseContext">The database context to work with.</param>
        /// <param name="ex">The exception that caused the failure.</param>
        /// <param name="host">The host inside that failed the query.</param>
        private void DoRecordFailingBgpQueryEntry(QueryResultDatabaseContext databaseContext, Exception ex, IHamnetDbHost host)
        {
            var failingHost  = host.Address.ToString();
            var failEntry    = databaseContext.BgpFailingQueries.Find(failingHost);
            var hamnetSnmpEx = ex as HamnetSnmpException;

            if (failEntry == null)
            {
                failEntry = new BgpFailingQuery
                {
                    Host = failingHost
                };

                databaseContext.BgpFailingQueries.Add(failEntry);
            }

            failEntry.TimeStamp   = DateTime.UtcNow;
            failEntry.PenaltyInfo = this.failureRetryFilteringDataHandler?.QueryPenaltyDetails(QueryType.BgpQuery, host.Address);

#if DEBUG
            failEntry.ErrorInfo = ex?.ToString() ?? string.Empty;
#else
            failEntry.ErrorInfo = ex?.Message ?? string.Empty;
#endif
        }