Skip to content

PgErrorContext

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Adds a line of context to the errors and messages reported while it is active, as a C extension’s error context callback does, such as which remote transaction an apply worker is applying.

public sealed class PgErrorContext : IDisposable

PostgreSQL adds the text to the context field of every error, warning and log message raised by a backend call made while the context is active, after any inner lines, and to errors that a managed exception thrown while it is active becomes. Change [Text](/api/ankus.pgerrorcontext/#member-9d59fb9d20bed3f3) as the work moves on; PostgreSQL never calls back into .NET to build it.

Contexts nest, and disposing one removes it. A callback's contexts are removed when it returns, so a forgotten one cannot describe later errors; a background worker's contexts last until it disposes them or exits. A context belongs to the thread that pushed it.

Inheritance: object

Implements: IDisposable

Removes the context.

public void Dispose()

Makes a context active until it is disposed.

public static PgErrorContext Push(string text)

Parameters:

text — string

The line to add, such as applying remote transaction 742.

Returns: PgErrorContext

The active context.

Gets or sets the context’s text.

public string Text { get; set; }

Value: string

Exceptions: