public sealed record PlatformDiagnostic : IEquatable<PlatformDiagnostic> 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
DomainThe native error space:
HRESULT,Win32,errno,OSStatus,IOReturn, anNSErrororGErrordomain, a D-Bus error name, ororg.freedesktop.portal.Requestfor a portal response code.CodeThe 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.
MessageA 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
DomainThe native error space:
HRESULT,Win32,errno,OSStatus,IOReturn, anNSErrororGErrordomain, a D-Bus error name, ororg.freedesktop.portal.Requestfor a portal response code.CodeThe 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.
MessageA 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
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.