PlatformDiagnostic record

Namespace Runic.Platform · Runic.Platform 0.7.0-preview.5

public sealed record PlatformDiagnostic : IEquatable<PlatformDiagnostic>

Inherits or implements IEquatable.

Native error detail attached to a failure for logs and support. It is not intended for display and may be localized by the operating system. Messages come only from operating-system error tables or fixed provider text; free-form text from native services (GError and D-Bus messages, NSError descriptions) is omitted, so a diagnostic contains no paths, file contents or native handles.

Parameters

Domain

The native error space: HRESULT, Win32, errno, OSStatus, IOReturn, an NSError or GError domain, a D-Bus error name, or org.freedesktop.portal.Request for a portal response code.

Code

The native numeric code. HRESULT and IOReturn codes keep their unsigned 32-bit value; the code is zero when the domain itself names the error, as D-Bus error names do.

Message

A native description, when one is available.

Remarks

The factories describe a code only on the platform that defines it: HRESULT and Win32 codes on Windows, errno on other systems. Elsewhere PlatformDiagnostic.Message is null.

Constructors

PlatformDiagnostic

public PlatformDiagnostic(string Domain, long Code, string? Message = null)

Native error detail attached to a failure for logs and support. It is not intended for display and may be localized by the operating system. Messages come only from operating-system error tables or fixed provider text; free-form text from native services (GError and D-Bus messages, NSError descriptions) is omitted, so a diagnostic contains no paths, file contents or native handles.

Parameters

Domain

The native error space: HRESULT, Win32, errno, OSStatus, IOReturn, an NSError or GError domain, a D-Bus error name, or org.freedesktop.portal.Request for a portal response code.

Code

The native numeric code. HRESULT and IOReturn codes keep their unsigned 32-bit value; the code is zero when the domain itself names the error, as D-Bus error names do.

Message

A native description, when one is available.

Remarks

The factories describe a code only on the platform that defines it: HRESULT and Win32 codes on Windows, errno on other systems. Elsewhere PlatformDiagnostic.Message is null.

Properties

Code

public long Code { get; init; }

The native numeric code. HRESULT and IOReturn codes keep their unsigned 32-bit value; the code is zero when the domain itself names the error, as D-Bus error names do.

Domain

public string Domain { get; init; }

The native error space: HRESULT, Win32, errno, OSStatus, IOReturn, an NSError or GError domain, a D-Bus error name, or org.freedesktop.portal.Request for a portal response code.

Message

public string? Message { get; init; }

A native description, when one is available.

Methods

FromErrno

public static PlatformDiagnostic FromErrno(int errno)

Describes a POSIX errno value.

FromHResult

public static PlatformDiagnostic FromHResult(int hresult)

Describes a COM or Windows Runtime HRESULT.

FromWin32Error

public static PlatformDiagnostic FromWin32Error(int error)

Describes a Win32 error code, such as the value of GetLastError.

ToString

public override string ToString()

Formats the diagnostic as Domain Code: Message.