CkUuidException
What CkUuid throws — only when asked.
Raised by any CkUuid method called with
throwIfInvalid: true when a value could not be used as a UUID (a universally
unique identifier). Never thrown otherwise: by default those methods answer '',
the nil UUID, or — for Version — your numeric fallback instead — and ToUuidOrNull
cannot raise it at all: it takes no throwIfInvalid and never throws, null is its
answer for any error. Final, 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:
CkUuid.Canonical: cannot use "junk" (String) as a UUID — not a UUID in a known shape.
Properties
Every property is public readonly.
| Property | Type | What it holds |
|---|---|---|
Expected |
string |
What the value was meant to be — 'a UUID', 'an output shape'. |
Input |
mixed |
From CkException: the value that failed, untouched. |
Reason |
string |
From CkException: why, in a few words. |
Quick look
use SafeCoder\CommonKit\CkUuid;
use SafeCoder\CommonKit\Exceptions\CkUuidException;
try {
CkUuid::Canonical(
input: 'junk',
throwIfInvalid: true
);
} catch (CkUuidException $error) {
echo $error->Reason; // -> 'not a UUID in a known shape'
echo $error->Expected; // -> 'a UUID'
}