CkIPException
What CkIP throws — only when asked.
Raised by any CkIP method called with throwIfInvalid: true
when a value could not be used. Never thrown otherwise: by default every CkIP method
returns empty, false or the fallback instead. Sealed, and derived from
CkException.
The message names the method, shows the value with its type, says what it was meant to be and why it failed:
CkIP.Address: cannot use "127.1" (String) as an IP address — not four dot-separated numbers.
Properties
| Property | Type | What it holds |
|---|---|---|
Expected |
string |
What the value was meant to be — "an IP address". |
Input |
object? |
From CkException: the value that failed, untouched. |
Reason |
string |
From CkException: why, in a few words. |
Quick look
using SafeCoder.CommonKit;
using SafeCoder.CommonKit.Exceptions;
try
{
CkIP.Address(
input: "127.1",
throwIfInvalid: true
);
}
catch (CkIPException error)
{
Console.WriteLine(error.Reason); // -> "not four dot-separated numbers"
Console.WriteLine(error.Expected); // -> "an IP address"
}