Skip to main content

Module erc

Module erc 

Source
Expand description

BDEW ERC error codes — structured rejection codes for APERAK and CONTRL.

BDEW ERC codes appear in:

  • APERAK ERC segments: processability errors returned by the receiving party when it cannot process a message (BGM+313).

CONTRL carries no ERC: it reports a syntax failure in UCI/UCM DE 0085, which is a different vocabulary and not this module’s.

This module provides a validated ErcCode newtype, a catalogue of standard code string constants in codes, and ErcAction — a machine-readable recommended automated response for each code. Domain crates match on the ERC code to drive typed ERP automation instead of freeform text parsing.

§Separation of concerns

LayerResponsibility
edi-energyWire-format parsing; raw String from ERC segment
mako-engine::ercValidated type; constants; role-agnostic ErcAction recommendation
Domain cratesProcess-specific match on ErcCode → domain decision
makodErcCode in outbox payload → makoerc CloudEvents extension

§Regulatory sources

  • APERAK MIG 2.1i / 2.2 — SG4 ERC C901 DE 9321, the code table
  • APERAK AHB 1.0 / 1.1 — which codes each Anwendungsfall admits, and the Bedingungen that oblige the SG5 FTX+Z02 Ortsangabe
  • Allgemeine Festlegungen V6.1d (01.04.2026) — §4 rejection handling

§Example

use mako_engine::erc::{ErcCode, ErcAction, codes, recommended_action};

let code = ErcCode::new(codes::Z39);
assert!(matches!(
    recommended_action(&code),
    ErcAction::RetryWithCorrection { field: "message" }
));

Modules§

codes
The ERC DE 9321 „Anwendungsfehler, Code“ values, verbatim from the APERAK MIG 2.1i code table. There is no second vocabulary: CONTRL reports syntax failures in UCI/UCM DE 0085, not in an ERC, and a code outside this list is refused by the receiving Marktpartner’s own Prüfschablone.

Structs§

ErcCode
A BDEW ERC DE 9321 error code from an inbound APERAK.

Enums§

ErcAction
Recommended automated response for a received ERC rejection code.

Functions§

recommended_action
Return the recommended automated ERP action for a received ERC code.
requires_ortsangabe
Whether an ERC code obliges the SG5 FTX+Z02 Ortsangabe des AHB-Fehlers.