mishima-nexus-client-csharp/src/Robotico.Nexus.Client/NexusErrors.cs

47 lines
2.1 KiB
C#
Raw Normal View History

using Robotico.Result.Errors;
namespace Robotico.Nexus.Client;
/// <summary>Stable error codes for <see cref="Robotico.Nexus.Client"/>.</summary>
public static class NexusErrors
{
/// <summary>General Nexus client failure.</summary>
public const string Code = "NXS_NEXUS";
/// <summary>Connection URI failed to parse or uses an unsupported form.</summary>
public const string UriInvalid = "NXS_URI_INVALID";
/// <summary>Connection URI scheme is recognized but not supported by this client.</summary>
public const string UnsupportedScheme = "NXS_URI_UNSUPPORTED_SCHEME";
/// <summary>The gRPC channel could not be created (TLS material, address, or transport failure).</summary>
public const string ConnectFailed = "NXS_CONNECT_FAILED";
/// <summary>TLS/mTLS material was rejected or missing required files.</summary>
public const string TlsRejected = "NXS_TLS_REJECTED";
/// <summary>Create was called for a database that already answers to Ping.</summary>
public const string AlreadyExists = "NXS_ALREADY_EXISTS";
/// <summary>Requested resource was not found on the remote engine.</summary>
public const string NotFound = "NXS_NOT_FOUND";
/// <summary>Invalid argument (empty name, bad range, unknown wire type).</summary>
public const string InvalidArgument = "NXS_INVALID_ARGUMENT";
/// <summary>Operation attempted on a disposed client/session.</summary>
public const string Disposed = "NXS_DISPOSED";
/// <summary>Remote engine is unreachable or the call exceeded its deadline.</summary>
public const string Unavailable = "NXS_UNAVAILABLE";
/// <summary>Generic wire/gRPC failure not covered by a more specific code.</summary>
public const string WireFailed = "NXS_WIRE_FAILED";
/// <summary>Creates a <see cref="SimpleError"/> with <see cref="Code"/>.</summary>
public static SimpleError Error(string message) => new(message, Code);
/// <summary>Creates a <see cref="SimpleError"/> with an explicit code.</summary>
public static SimpleError Error(string message, string code) => new(message, code);
}