RaspberryIO/Unosquare.Swan/Exceptions/DnsQueryException.cs
2019-12-03 18:44:25 +01:00

31 lines
917 B
C#

using System;
using Unosquare.Swan.Networking;
namespace Unosquare.Swan.Exceptions {
/// <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) => this.Response = response;
internal DnsClient.IDnsResponse Response {
get;
}
private static String Format(DnsClient.IDnsResponse response) => $"Invalid response received with code {response.ResponseCode}";
}
}