Class BowireStreamErrorEnvelope

Namespace
Kuestenlogik.Bowire
Assembly
Kuestenlogik.Bowire.dll

The envelope a JSON-only streaming plugin yields to end a stream with a reason (#712).

public static class BowireStreamErrorEnvelope
Inheritance
BowireStreamErrorEnvelope
Inherited Members

Remarks

InvokeStreamAsync(string, string, string, List<string>, bool, Dictionary<string, string>?, CancellationToken) yields strings, so a plugin on that path has no typed slot to put an error in. It yields this envelope as its last frame instead. Plugins that implement IBowireStreamingWithWireBytes set Error directly and do not need it.

The key is deliberately unlovely. It has to be something no server's payload would ever contain at its top level, because the alternative — a bare error key — is exactly what several plugins already emit as *data*, and a consumer cannot tell those apart from a stream that actually ended.

Fields

Key

The reserved top-level key.

public const string Key = "__bowireStreamError"

Field Value

string

Methods

Frame(StreamError)

The frame to yield as the last one on a stream that failed.

public static string Frame(StreamError error)

Parameters

error StreamError

Returns

string

Frame(string, string, string?)

Convenience for the common call: build the frame from its parts.

public static string Frame(string kind, string message, string? code = null)

Parameters

kind string
message string
code string

Returns

string

TryRead(string?)

The error a frame carries, or null when it is ordinary data.

public static StreamError? TryRead(string? frameJson)

Parameters

frameJson string

Returns

StreamError

Remarks

Anything that is not a JSON object with the reserved key is data. That includes malformed JSON: a plugin is free to stream whatever a server sent, and deciding that unparseable output means "error" would put words in the server's mouth.