Path: redb-route/redb.Route.As4/As4ErrorCode.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.As4/As4ErrorCode.cs
----
namespace redb.Route.As4;
/// Severity of an ebMS error (ebMS 3.0 Core §6.3).
public enum As4ErrorSeverity
{
/// The message unit in error is not processed further.
Failure,
/// Processing continued; the partner is only informed.
Warning,
}
///
/// An ebMS 3.0 error code (Core §6.7, AS4 profile §3) with its short description, category and default
/// severity, and the fixed text we send to a partner for it. A received message never gets the text of one of
/// our exceptions back (BR-4): that text names our files, connections and services; the partner gets this
/// description and a reference to quote.
///
public sealed record As4ErrorCode(string Code, string ShortDescription, string Category, As4ErrorSeverity Severity, string PartnerText)
{
/// EBMS:0001 — a value of the message is not recognized (unknown agreement, party, service, action).
public static readonly As4ErrorCode ValueNotRecognized = new("EBMS:0001", "ValueNotRecognized", "Content", As4ErrorSeverity.Failure,
"A value of the message header is not recognized for any agreement.");
/// EBMS:0002 — a feature the message asks for is not supported.
public static readonly As4ErrorCode FeatureNotSupported = new("EBMS:0002", "FeatureNotSupported", "Content", As4ErrorSeverity.Warning,
"A feature the message asks for is not supported.");
/// EBMS:0003 — values of the message contradict each other or the agreement.
public static readonly As4ErrorCode ValueInconsistent = new("EBMS:0003", "ValueInconsistent", "Content", As4ErrorSeverity.Failure,
"Values of the message are inconsistent.");
/// EBMS:0004 — any other failure; for us, a failure of the receiving route.
public static readonly As4ErrorCode Other = new("EBMS:0004", "Other", "Content", As4ErrorSeverity.Failure,
"The message could not be processed.");
/// EBMS:0005 — the receiving MSH could not be reached (reported locally by a sender). Not raised by this connector: a send that cannot connect is an HttpRequestException the route handles.
public static readonly As4ErrorCode ConnectionFailure = new("EBMS:0005", "ConnectionFailure", "Communication", As4ErrorSeverity.Failure,
"The receiving MSH could not be reached.");
/// EBMS:0006 — a pulled partition channel is empty (pull only). Reserved for pull (phase 10, out of scope).
public static readonly As4ErrorCode EmptyMessagePartitionChannel = new("EBMS:0006", "EmptyMessagePartitionChannel", "Communication", As4ErrorSeverity.Warning,
"The message partition channel holds no message.");
/// EBMS:0007 — the MIME structure does not match the header's payload references.
public static readonly As4ErrorCode MimeInconsistency = new("EBMS:0007", "MimeInconsistency", "Unpackaging", As4ErrorSeverity.Failure,
"The MIME parts do not match the payload references of the message header.");
/// EBMS:0009 — the ebMS header is missing or malformed.
public static readonly As4ErrorCode InvalidHeader = new("EBMS:0009", "InvalidHeader", "Unpackaging", As4ErrorSeverity.Failure,
"The ebMS header is missing or malformed.");
/// EBMS:0010 — the message does not match the processing mode of its agreement.
public static readonly As4ErrorCode ProcessingModeMismatch = new("EBMS:0010", "ProcessingModeMismatch", "Processing", As4ErrorSeverity.Failure,
"The message does not match the processing mode of its agreement.");
/// EBMS:0011 — a payload referenced outside the message could not be used.
public static readonly As4ErrorCode ExternalPayloadError = new("EBMS:0011", "ExternalPayloadError", "Content", As4ErrorSeverity.Failure,
"Payloads outside the message are not supported.");
/// EBMS:0101 — the signature (or anything it protects) did not verify.
public static readonly As4ErrorCode FailedAuthentication = new("EBMS:0101", "FailedAuthentication", "Processing", As4ErrorSeverity.Failure,
"The security check of the message failed.");
/// EBMS:0102 — the message could not be decrypted.
public static readonly As4ErrorCode FailedDecryption = new("EBMS:0102", "FailedDecryption", "Processing", As4ErrorSeverity.Failure,
"The security check of the message failed.");
/// EBMS:0103 — the message is not secured the way the agreement requires.
public static readonly As4ErrorCode PolicyNoncompliance = new("EBMS:0103", "PolicyNoncompliance", "Processing", As4ErrorSeverity.Failure,
"The message is not secured as the agreement requires.");
/// EBMS:0201 — reliability processing failed. Not raised: reliability is the engine's redelivery.
public static readonly As4ErrorCode DysfunctionalReliability = new("EBMS:0201", "DysfunctionalReliability", "Processing", As4ErrorSeverity.Failure,
"Reliable messaging processing failed.");
/// EBMS:0202 — the message could not be delivered to its consumer. Not raised today: a route failure is answered EBMS:0004 (Other).
public static readonly As4ErrorCode DeliveryFailure = new("EBMS:0202", "DeliveryFailure", "Communication", As4ErrorSeverity.Failure,
"The message could not be delivered.");
/// EBMS:0301 — no receipt arrived for a message that required one (sender side).
public static readonly As4ErrorCode MissingReceipt = new("EBMS:0301", "MissingReceipt", "Communication", As4ErrorSeverity.Failure,
"No receipt was received for the message.");
/// EBMS:0302 — a receipt arrived but does not prove receipt of what was sent (sender side).
public static readonly As4ErrorCode InvalidReceipt = new("EBMS:0302", "InvalidReceipt", "Communication", As4ErrorSeverity.Failure,
"The receipt does not match the message.");
/// EBMS:0303 — a compressed payload could not be decompressed.
public static readonly As4ErrorCode DecompressionFailure = new("EBMS:0303", "DecompressionFailure", "Communication", As4ErrorSeverity.Failure,
"A payload could not be decompressed.");
private static readonly IReadOnlyDictionary ByCode = new[]
{
ValueNotRecognized, FeatureNotSupported, ValueInconsistent, Other, ConnectionFailure, EmptyMessagePartitionChannel,
MimeInconsistency, InvalidHeader, ProcessingModeMismatch, ExternalPayloadError, FailedAuthentication, FailedDecryption,
PolicyNoncompliance, DysfunctionalReliability, DeliveryFailure, MissingReceipt, InvalidReceipt, DecompressionFailure,
}.ToDictionary(c => c.Code, StringComparer.Ordinal);
/// The known code named (EBMS:0009), or null for a code we do not know.
public static As4ErrorCode? Find(string? code) => code is not null && ByCode.TryGetValue(code, out var known) ? known : null;
}