Class SseFailureMessage
- Namespace
- SseAssertions
- Assembly
- SseAssertions.dll
Curated factory methods for SSE assertion failure messages. Exposed as the v0.1.0+ extension
point for consumer-authored typed SSE assertions: a consumer who writes their own
[GenerateAssertion]-tagged extension can compose these factories to produce failure
messages whose shape matches the shipped chain terminators.
public static class SseFailureMessage
- Inheritance
-
SseFailureMessage
- Inherited Members
Remarks
All factories return culture-invariant strings using InvariantCulture
for any numeric formatting. Truncation rules are consistent across factories:
per-event Data fields are truncated at 80 characters with a trailing …
(U+2026 HORIZONTAL ELLIPSIS); body-context excerpts in ParseFailure(string) and
the partialBodyExcerpt argument of
CancellationCutRead(int, int, string) are truncated at 256 characters with the
same suffix.
The factories mirror the
JsonAssertions.JsonFailureMessage and MathAssertions.MathFailureMessage patterns
in sibling family packages.
Methods
CancellationCutRead(int, int, string)
Produces the failure message for a cancelled read whose partial buffer did not satisfy the chain.
public static string CancellationCutRead(int bytesReceived, int eventsParsed, string partialBodyExcerpt)
Parameters
bytesReceivedintThe number of bytes received before cancellation fired.
eventsParsedintThe number of fully-terminated events the parser recovered from the partial buffer.
partialBodyExcerptstringThe first
256characters of the partial buffer (truncated with a trailing…when longer).
Returns
- string
A failure message describing the cancellation-bounded read result.
Exceptions
- ArgumentNullException
partialBodyExcerptis null.
DataDeserializationFailed(string, string, Exception)
Produces the failure message for an exception thrown by the data deserializer.
public static string DataDeserializationFailed(string eventName, string data, Exception inner)
Parameters
eventNamestringThe event-type name the chain asked for.
datastringThe raw
Datavalue the deserializer was applied to (truncated at80characters).innerExceptionThe exception the deserializer threw.
Returns
- string
A failure message including the exception type, message, and the offending (truncated) data value.
Exceptions
- ArgumentNullException
Any of
eventName,data, orinneris null.
DataPredicateNotMatched(string, IReadOnlyList<string>)
Produces the failure message for "data predicate did not match any event".
public static string DataPredicateNotMatched(string eventName, IReadOnlyList<string> dataValues)
Parameters
eventNamestringThe event-type name the chain asked for.
dataValuesIReadOnlyList<string>The
Datavalues of every event of the requested type observed in the stream (each rendered truncated at80characters).
Returns
- string
A failure message listing every observed
Datavalue so the consumer can see why the predicate did not match.
Exceptions
- ArgumentNullException
eventNameordataValuesis null.
EventCountMismatch(string, int, int, SseCountComparison)
Produces the failure message for an event-count terminator failure.
public static string EventCountMismatch(string eventName, int expected, int actual, SseCountComparison comparison)
Parameters
eventNamestringThe event-type name the chain asked for.
expectedintThe expected count (the value passed to the terminator).
actualintThe actual matching-event count observed.
comparisonSseCountComparisonThe comparison label the chain used.
Returns
- string
A failure message describing the count mismatch.
Exceptions
- ArgumentNullException
eventNameis null.
EventNotFound(string, IReadOnlyList<SseEvent>)
Produces the failure message for "no event of the requested name was found".
public static string EventNotFound(string eventName, IReadOnlyList<SseEvent> available)
Parameters
eventNamestringThe event-type name the chain asked for.
availableIReadOnlyList<SseEvent>The full list of events observed in the stream (rendered for diagnosis; per-event
Datatruncated at80characters).
Returns
- string
A failure message listing every observed event so the consumer can see why the requested event was not found.
Exceptions
- ArgumentNullException
eventNameoravailableis null.
IdNotMatched(string, string, IReadOnlyList<string?>)
Produces the failure message for "no event of the requested type carried the
expected id:".
public static string IdNotMatched(string eventName, string expectedId, IReadOnlyList<string?> idValues)
Parameters
eventNamestringThe event-type name the chain asked for.
expectedIdstringThe
id:value the chain required.idValuesIReadOnlyList<string>The
Idvalues of every event of the requested type observed in the stream (null entries represent frames without anid:directive).
Returns
- string
A failure message listing every observed
Idvalue so the consumer can see why none carried the expected id.
Exceptions
- ArgumentNullException
eventName,expectedId, oridValuesis null.
ParseFailure(string)
Produces the failure message for an SSE body that could not be parsed.
public static string ParseFailure(string body)
Parameters
bodystringThe body that failed to parse. Embedded in the message, truncated at
256characters with a trailing….
Returns
- string
A failure message describing the parse failure with the truncated body excerpt.
Exceptions
- ArgumentNullException
bodyis null.
RetryMillisPredicateNotMatched(string, IReadOnlyList<int?>)
Produces the failure message for a retry-millis predicate failure.
public static string RetryMillisPredicateNotMatched(string eventName, IReadOnlyList<int?> retryValues)
Parameters
eventNamestringThe event-type name the chain asked for.
retryValuesIReadOnlyList<int?>The
RetryMillisvalues observed on every event of the requested type (null entries represent frames without aretry:directive).
Returns
- string
A failure message listing every observed retry value so the consumer can see why the predicate did not match.
Exceptions
- ArgumentNullException
eventNameorretryValuesis null.
UncleanCancellation(Exception)
Produces the failure message for a stream that did not tear down cleanly when its read was cancelled: a transport exception surfaced instead of cooperative cancellation.
public static string UncleanCancellation(Exception exception)
Parameters
exceptionExceptionThe exception that surfaced from the cancelled read.
Returns
- string
A failure message naming the exception type and message.
Exceptions
- ArgumentNullException
exceptionis null.
UnexpectedContentType(string?)
Produces the failure message for an HTTP response whose Content-Type was
not text/event-stream.
public static string UnexpectedContentType(string? actualContentType)
Parameters
actualContentTypestringThe actual
Content-Typemedia type observed on the response, or null when noContent-Typeheader was present.
Returns
- string
A failure message naming the expected SSE content type and the actual response content type.