RaspberryIO/Unosquare.Swan/Exceptions/DnsQueryException.cs

40 lines
1.0 KiB
C#
Raw Normal View History

2019-02-17 14:08:57 +01:00
namespace Unosquare.Swan.Exceptions
{
using System;
using Networking;
/// <summary>
/// An exception thrown when the DNS query fails.
/// </summary>
/// <seealso cref="System.Exception" />
public class DnsQueryException : Exception
{
internal DnsQueryException(string message)
: base(message)
{
}
internal DnsQueryException(string message, Exception e)
: base(message, e)
{
}
internal DnsQueryException(DnsClient.IDnsResponse response)
: this(response, Format(response))
{
}
internal DnsQueryException(DnsClient.IDnsResponse response, string message)
: base(message)
{
Response = response;
}
internal DnsClient.IDnsResponse Response { get; }
private static string Format(DnsClient.IDnsResponse response)
{
return $"Invalid response received with code {response.ResponseCode}";
}
}
}