Skip to content

CkPayloadException

What CkPayload throws — only when asked.

Raised by any CkPayload method called with throwIfInvalid: true when wire text — the raw body of a request or response — could not be turned into a dictionary. Never thrown otherwise: by default those methods answer an empty dictionary or list instead. Sealed, and derived from CkException.

The message names the method and says why the text could not be read:

CkPayload.FromJson: cannot read the payload — not valid JSON.

Properties

Property Type What it holds
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
{
    CkPayload.FromJson(
        json: "not json",
        throwIfInvalid: true
    );
}
catch (CkPayloadException error)
{
    Console.WriteLine(error.Reason);  // -> "not valid JSON"
    Console.WriteLine(error.Input);   // -> "not json"
}