CkWebException
What CkWeb throws — only when asked.
Raised by any CkWeb method called with
throwIfInvalid: true when neither the value nor the fallback can be used. Never
thrown otherwise: by default those methods answer '' or false instead. 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:
CkWeb.Url: cannot use "ftp://x.com" (String) as a web address — not an http or https URL.
Properties
Every property is public readonly.
| Property | Type | What it holds |
|---|---|---|
Expected |
string |
What the value was meant to be — 'a web address'. |
Input |
mixed |
From CkException: the value that failed, untouched. |
Reason |
string |
From CkException: why, in a few words. |
Quick look
use SafeCoder\CommonKit\CkWeb;
use SafeCoder\CommonKit\Exceptions\CkWebException;
try {
CkWeb::Url(
input: 'ftp://x.com',
throwIfInvalid: true
);
} catch (CkWebException $error) {
echo $error->Reason; // -> 'not an http or https URL'
echo $error->Expected; // -> 'a web address'
}