CkFileException
What CkFile throws — only when asked.
Raised by any CkFile method called with
throwIfInvalid: true when a value could not be used. Never thrown otherwise: by
default every CkFile method returns empty or false 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:
CkFile.RelativePath: cannot use "../secrets.txt" (String) as a relative path — it climbs out of its folder (..).
Properties
| Property | Type | What it holds |
|---|---|---|
Expected |
string |
What the value was meant to be — "a file name", "a relative path". |
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
{
CkFile.RelativePath(
input: "../secrets.txt",
throwIfInvalid: true
);
}
catch (CkFileException error)
{
Console.WriteLine(error.Reason); // -> "it climbs out of its folder (..)"
Console.WriteLine(error.Expected); // -> "a relative path"
}