RaspberryIO_26/Swan/Net/Dns/DnsQueryException.cs
2019-12-08 21:23:54 +01:00

29 lines
865 B
C#

#nullable enable
using System;
namespace Swan.Net.Dns {
/// <summary>
/// An exception thrown when the DNS query fails.
/// </summary>
/// <seealso cref="Exception" />
[Serializable]
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}";
}
}