#[non_exhaustive]pub enum Error {
Show 22 variants
Parse(EdifactError),
Serialize(String),
FeatureNotEnabled {
message_type: String,
feature: String,
},
UnknownMessageType {
raw_code: String,
},
MissingSegment(&'static str),
MalformedSegment(&'static str),
MissingPruefidentifikator,
InvalidPruefidentifikatorRange(u32),
InvalidPruefidentifikatorFormat {
raw_value: String,
},
MissingRelease,
InvalidRelease(&'static str),
ProfileNotFound {
message_type: MessageType,
release: Release,
},
ProfileArchived {
message_type: MessageType,
release: Release,
feature_flag: &'static str,
},
ProfileNotYetActive {
message_type: MessageType,
release: Release,
valid_from: Date,
date: Date,
},
ProfileExpired {
message_type: MessageType,
release: Release,
valid_until: Date,
date: Date,
},
Validation {
count: usize,
report: EdiEnergyReport,
},
Io(Error),
Profile(ProfileError),
InterchangeCountMismatch {
declared: usize,
actual: usize,
},
InterchangeRefMismatch {
unb_ref: String,
unz_ref: String,
},
TooManyMessages {
limit: usize,
},
TooManySegmentsInMessage {
limit: usize,
actual: usize,
},
}Expand description
All errors that can be produced by edi-energy.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Parse(EdifactError)
The underlying EDIFACT parser rejected the input.
Serialize(String)
Writing an EDIFACT structure failed (envelope or segment serialization).
Distinct from Parse: the input was accepted, but the
output could not be rendered — e.g. a value outside the UNOC character
set or beyond a data element’s length bound.
FeatureNotEnabled
The message type is known but the corresponding Cargo feature is not compiled in.
Enable the feature Cargo feature for this crate to parse message_type messages.
Fields
UnknownMessageType
The message type code from UNH is not recognised by this crate at all.
The raw code is not included in Display output to avoid GDPR-sensitive
data leaking into operator logs. Access the code via the raw_code field
when needed for diagnostic purposes.
The raw_code value is sanitized at construction: characters outside
ASCII alphanumeric and . are replaced with ? so log-injection sequences
are neutralized before the value enters any tracing span or log record.
Fields
MissingSegment(&'static str)
A mandatory EDIFACT segment is absent from the message.
MalformedSegment(&'static str)
A segment was found but its content is structurally invalid.
MissingPruefidentifikator
The BGM document-identifier field (Pruefidentifikator) was not present.
InvalidPruefidentifikatorRange(u32)
A parsed Pruefidentifikator is outside the valid 5-digit range (10000–99999).
The invalid numeric value is carried as context for diagnostic messages.
InvalidPruefidentifikatorFormat
The Pruefidentifikator field is not a decimal integer at all.
The raw field value is not included in Display output to avoid GDPR-sensitive
data (process codes) leaking into operator logs. Access via raw_value field
for diagnostic purposes. This is distinct from
Error::InvalidPruefidentifikatorRange so callers can cleanly distinguish
“wrong number” from “not a number”.
Fields
MissingRelease
The release / association-code field in UNH was absent or empty.
InvalidRelease(&'static str)
A release code supplied to Release::try_new failed validation.
ProfileNotFound
No profile was registered for the given message type + release combination.
Run cargo xtask codegen to generate profile data from profiles/**.
Fields
message_type: MessageTypeThe EDIFACT message type.
ProfileArchived
The requested profile is compiled out — enable the feature flag to include it.
This error is returned when the release/message-type combination is a known
archived profile that exists in the edi-energy codebase but is excluded
from the current build by a feature gate (e.g. contrl-archive, mscons-archive,
insrpt-archive, or the catch-all archive feature).
§How to fix
Add the required feature to your Cargo.toml:
[dependencies]
edi-energy = { version = "...", features = ["contrl-archive"] }§Background
Archived profiles are kept in the source tree for retroactive validation
(audit / dispute resolution) but excluded from default builds to keep
binary size and compile times small. For the contrl message type, the
archived FV2025-10-01 profile covers interchanges from October 2025 –
December 2025 (before contrl_fv20260101 became active on 2026-01-01).
Fields
message_type: MessageTypeThe EDIFACT message type.
ProfileNotYetActive
The requested profile exists but has not yet become normatively valid on date.
The profile’s valid_from is in the future relative to the processing date.
Either use a later processing date, or accept the outgoing profile for now.
Fields
message_type: MessageTypeThe EDIFACT message type.
ProfileExpired
The requested profile has expired on date.
The profile’s valid_until date is before the processing date.
Use the successor profile that is valid on this date instead.
Fields
message_type: MessageTypeThe EDIFACT message type.
Validation
Validation completed but the report contains at least one error-level issue.
Inspect EdiEnergyReport for the full list of findings.
Fields
report: EdiEnergyReportThe full validation report.
Io(Error)
A wrapped I/O error (e.g. from reader-based parsing).
Profile(ProfileError)
A profile configuration error (bad or missing profile data).
This error is returned when a programmatically constructed profile omits
mandatory fields. Profiles generated by cargo xtask codegen never
produce this error.
InterchangeCountMismatch
The UNZ message count does not match the number of UNH…UNT pairs found in the interchange.
Indicates a truncated, padded, or tampered interchange.
Fields
InterchangeRefMismatch
The interchange control reference in UNZ does not match the one in UNB.
Per EDIFACT syntax, UNZ DE 0036 must equal UNB DE 0020.
Fields
TooManyMessages
The interchange exceeds the configured max_messages_per_interchange limit.
Increase crate::ParseConfig::max_messages_per_interchange or process a
smaller interchange.
TooManySegmentsInMessage
A single EDIFACT message (UNH…UNT) exceeds the configured
max_segments_per_message limit.
Increase crate::ParseConfig::max_segments_per_message or reject the
oversized message. This limit is a DoS defence for the inbound parser path.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<EdifactError> for Error
impl From<EdifactError> for Error
Source§fn from(source: EdifactError) -> Self
fn from(source: EdifactError) -> Self
Source§impl From<ProfileError> for Error
impl From<ProfileError> for Error
Source§fn from(source: ProfileError) -> Self
fn from(source: ProfileError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more