Skip to content

CkIntlException

What CkIntl throws — only when asked.

Raised by any CkIntl method called with throwIfInvalid: true when neither the value nor the fallback can be used. Never thrown otherwise: by default those methods answer "" instead — and the …Mask methods, made for display, answer a masked shape and never throw at all. 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:

CkIntl.Phone: cannot use "junk" (String) as a phone number in international form — no international prefix: it must start with +, 00 or 011.

Properties

Property Type What it holds
Expected string What the value was meant to be — "a phone number in international form", "an IBAN" or "a BIC", depending on the method.
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
{
    CkIntl.Phone(
        input: "junk",
        throwIfInvalid: true
    );
}
catch (CkIntlException error)
{
    Console.WriteLine(error.Reason);    // -> "no international prefix: it must start with +, 00 or 011"
    Console.WriteLine(error.Expected);  // -> "a phone number in international form"
}