Skip to main content

ErrorCode

Enum ErrorCode 

Source
pub enum ErrorCode {
Show 61 variants CBKP001_SYNTAX, CBKP011_UNSUPPORTED_CLAUSE, CBKP021_ODO_NOT_TAIL, CBKP022_NESTED_ODO, CBKP023_ODO_REDEFINES, CBKP051_UNSUPPORTED_EDITED_PIC, CBKP101_INVALID_PIC, CBKS121_COUNTER_NOT_FOUND, CBKS141_RECORD_TOO_LARGE, CBKS301_ODO_CLIPPED, CBKS302_ODO_RAISED, CBKS601_RENAME_UNKNOWN_FROM, CBKS602_RENAME_UNKNOWN_THRU, CBKS603_RENAME_NOT_CONTIGUOUS, CBKS604_RENAME_REVERSED_RANGE, CBKS605_RENAME_FROM_CROSSES_GROUP, CBKS606_RENAME_THRU_CROSSES_GROUP, CBKS607_RENAME_CROSSES_OCCURS, CBKS608_RENAME_QUALIFIED_NAME_NOT_FOUND, CBKS609_RENAME_OVER_REDEFINES, CBKS610_RENAME_MULTIPLE_REDEFINES, CBKS611_RENAME_PARTIAL_OCCURS, CBKS612_RENAME_ODO_NOT_SUPPORTED, CBKS701_PROJECTION_INVALID_ODO, CBKS702_PROJECTION_UNRESOLVED_ALIAS, CBKS703_PROJECTION_FIELD_NOT_FOUND, CBKR211_RDW_RESERVED_NONZERO, CBKC201_JSON_WRITE_ERROR, CBKC301_INVALID_EBCDIC_BYTE, CBKD101_INVALID_FIELD_TYPE, CBKD301_RECORD_TOO_SHORT, CBKD302_EDITED_PIC_NOT_IMPLEMENTED, CBKD401_COMP3_INVALID_NIBBLE, CBKD410_ZONED_OVERFLOW, CBKD411_ZONED_BAD_SIGN, CBKD412_ZONED_BLANK_IS_ZERO, CBKD413_ZONED_INVALID_ENCODING, CBKD414_ZONED_MIXED_ENCODING, CBKD415_ZONED_ENCODING_AMBIGUOUS, CBKD421_EDITED_PIC_INVALID_FORMAT, CBKD422_EDITED_PIC_SIGN_MISMATCH, CBKD423_EDITED_PIC_BLANK_WHEN_ZERO, CBKD431_FLOAT_NAN, CBKD432_FLOAT_INFINITY, CBKI001_INVALID_STATE, CBKE501_JSON_TYPE_MISMATCH, CBKE505_SCALE_MISMATCH, CBKE510_NUMERIC_OVERFLOW, CBKE515_STRING_LENGTH_VIOLATION, CBKE521_ARRAY_LEN_OOB, CBKE530_SIGN_SEPARATE_ENCODE_ERROR, CBKE531_FLOAT_ENCODE_OVERFLOW, CBKF102_RECORD_LENGTH_INVALID, CBKF104_RDW_SUSPECT_ASCII, CBKF221_RDW_UNDERFLOW, CBKA001_BASELINE_ERROR, CBKW001_SCHEMA_CONVERSION, CBKW002_TYPE_MAPPING, CBKW003_DECIMAL_OVERFLOW, CBKW004_BATCH_BUILD, CBKW005_PARQUET_WRITE,
}
Expand description

Stable error codes for programmatic error handling

The copybook-rs error taxonomy uses a structured approach with stable error codes that enable programmatic error handling across all components. Each code follows the pattern CBK[Category][Number]_[Description] where:

  • CBKP: Parse errors during copybook analysis
  • CBKS: Schema validation and ODO processing
  • CBKR: Record format and RDW processing
  • CBKC: Character conversion and encoding
  • CBKD: Data decoding and field validation
  • CBKE: Encoding and JSON serialization
  • CBKF: File format and structure validation
  • CBKI: Iterator and infrastructure state validation (e.g., fixed-format without LRECL -> CBKI001_INVALID_STATE)

Implements Serialize/Deserialize for error code persistence and API responses.

§Examples

use copybook_error::ErrorCode;

let code = ErrorCode::CBKP001_SYNTAX;
assert_eq!(code.family_prefix(), "CBKP");
assert_eq!(format!("{code}"), "CBKP001_SYNTAX");

let data_code = ErrorCode::CBKD301_RECORD_TOO_SHORT;
assert_eq!(data_code.family_prefix(), "CBKD");

Variants§

§

CBKP001_SYNTAX

CBKP001: General copybook syntax error during parsing

§

CBKP011_UNSUPPORTED_CLAUSE

CBKP011: Unsupported COBOL clause or feature encountered

§

CBKP021_ODO_NOT_TAIL

CBKP021: ODO (OCCURS DEPENDING ON) array not at tail position

§

CBKP022_NESTED_ODO

CBKP022: Nested ODO (OCCURS DEPENDING ON inside another OCCURS/ODO)

§

CBKP023_ODO_REDEFINES

CBKP023: ODO (OCCURS DEPENDING ON) over REDEFINES

§

CBKP051_UNSUPPORTED_EDITED_PIC

CBKP051: Unsupported edited PIC clause pattern

§

CBKP101_INVALID_PIC

CBKP101: Invalid PIC clause syntax or illegal characters

§

CBKS121_COUNTER_NOT_FOUND

CBKS121: ODO counter field not found in schema

§

CBKS141_RECORD_TOO_LARGE

CBKS141: Record size exceeds maximum allowable limit

§

CBKS301_ODO_CLIPPED

CBKS301: ODO count clipped to maximum allowed value (warning)

§

CBKS302_ODO_RAISED

CBKS302: ODO count raised to minimum required value (warning)

§

CBKS601_RENAME_UNKNOWN_FROM

CBKS601: RENAMES from field not found in scope

§

CBKS602_RENAME_UNKNOWN_THRU

CBKS602: RENAMES thru field not found in scope

§

CBKS603_RENAME_NOT_CONTIGUOUS

CBKS603: RENAMES range is not contiguous (gap between from and thru)

§

CBKS604_RENAME_REVERSED_RANGE

CBKS604: RENAMES range is reversed (from comes after thru)

§

CBKS605_RENAME_FROM_CROSSES_GROUP

CBKS605: RENAMES from field crosses group boundary

§

CBKS606_RENAME_THRU_CROSSES_GROUP

CBKS606: RENAMES thru field crosses group boundary

§

CBKS607_RENAME_CROSSES_OCCURS

CBKS607: RENAMES range crosses OCCURS boundary

§

CBKS608_RENAME_QUALIFIED_NAME_NOT_FOUND

CBKS608: RENAMES qualified name not found

§

CBKS609_RENAME_OVER_REDEFINES

CBKS609: RENAMES alias spans REDEFINES field(s) (R4 scenario)

§

CBKS610_RENAME_MULTIPLE_REDEFINES

CBKS610: RENAMES spans multiple REDEFINES alternatives (R4 scenario)

§

CBKS611_RENAME_PARTIAL_OCCURS

CBKS611: RENAMES spans partial array elements (R5 scenario)

§

CBKS612_RENAME_ODO_NOT_SUPPORTED

CBKS612: RENAMES with ODO arrays not supported (R5 scenario)

§

CBKS701_PROJECTION_INVALID_ODO

CBKS701: Field projection error - ODO array without accessible counter

§

CBKS702_PROJECTION_UNRESOLVED_ALIAS

CBKS702: Field projection error - RENAMES alias spans unselected fields

§

CBKS703_PROJECTION_FIELD_NOT_FOUND

CBKS703: Field projection error - selected field not found in schema

§

CBKR211_RDW_RESERVED_NONZERO

CBKR211: RDW reserved bytes contain non-zero values

§

CBKC201_JSON_WRITE_ERROR

CBKC201: JSON serialization write error

§

CBKC301_INVALID_EBCDIC_BYTE

CBKC301: Invalid EBCDIC byte encountered during conversion

§

CBKD101_INVALID_FIELD_TYPE

CBKD101: Invalid field type for requested operation

§

CBKD301_RECORD_TOO_SHORT

CBKD301: Record data too short for field requirements

§

CBKD302_EDITED_PIC_NOT_IMPLEMENTED

CBKD302: Edited PIC field encountered during decode (Phase E1: not implemented)

§

CBKD401_COMP3_INVALID_NIBBLE

CBKD401: Invalid packed decimal nibble value

§

CBKD410_ZONED_OVERFLOW

CBKD410: Zoned decimal value exceeded numeric capacity

§

CBKD411_ZONED_BAD_SIGN

CBKD411: Invalid zoned decimal sign zone

§

CBKD412_ZONED_BLANK_IS_ZERO

CBKD412: Zoned field contains all spaces (BLANK WHEN ZERO processing)

§

CBKD413_ZONED_INVALID_ENCODING

CBKD413: Invalid zoned decimal encoding format detected

§

CBKD414_ZONED_MIXED_ENCODING

CBKD414: Mixed ASCII/EBCDIC encoding within single zoned field

§

CBKD415_ZONED_ENCODING_AMBIGUOUS

CBKD415: Zoned encoding detection failed or remains ambiguous

§

CBKD421_EDITED_PIC_INVALID_FORMAT

CBKD421: Edited PIC decode failed - invalid format (mismatch between data and pattern)

§

CBKD422_EDITED_PIC_SIGN_MISMATCH

CBKD422: Edited PIC sign editing mismatch

§

CBKD423_EDITED_PIC_BLANK_WHEN_ZERO

CBKD423: Edited PIC blank when zero handling error

§

CBKD431_FLOAT_NAN

CBKD431: Floating-point field contains NaN (decoded as null)

§

CBKD432_FLOAT_INFINITY

CBKD432: Floating-point field contains infinity (decoded as null)

§

CBKI001_INVALID_STATE

CBKI001: Iterator or decoder encountered an invalid internal state

§

CBKE501_JSON_TYPE_MISMATCH

CBKE501: JSON value type doesn’t match expected field type

§

CBKE505_SCALE_MISMATCH

CBKE505: Decimal scale mismatch during field encoding

§

CBKE510_NUMERIC_OVERFLOW

CBKE510: Numeric value overflow for field capacity

§

CBKE515_STRING_LENGTH_VIOLATION

CBKE515: String length exceeds field size limit

§

CBKE521_ARRAY_LEN_OOB

CBKE521: Array length exceeds ODO bounds

§

CBKE530_SIGN_SEPARATE_ENCODE_ERROR

CBKE530: SIGN SEPARATE encode error

§

CBKE531_FLOAT_ENCODE_OVERFLOW

CBKE531: Float encode overflow (f64 value too large for f32 COMP-1 field)

§

CBKF102_RECORD_LENGTH_INVALID

CBKF102: RDW length field references incomplete or oversized payload

§

CBKF104_RDW_SUSPECT_ASCII

CBKF104: RDW appears to be corrupted by ASCII conversion

§

CBKF221_RDW_UNDERFLOW

CBKF221: RDW length field indicates underflow condition

§

CBKA001_BASELINE_ERROR

CBKA001: Performance baseline operation error

§

CBKW001_SCHEMA_CONVERSION

CBKW001: Failed COBOL to Arrow schema conversion

§

CBKW002_TYPE_MAPPING

CBKW002: FieldKind has no valid Arrow type mapping

§

CBKW003_DECIMAL_OVERFLOW

CBKW003: Decimal precision exceeds Decimal128 limit (38 digits)

§

CBKW004_BATCH_BUILD

CBKW004: RecordBatch construction failure

§

CBKW005_PARQUET_WRITE

CBKW005: Parquet file write failure

Implementations§

Source§

impl ErrorCode

Source

pub const fn family_prefix(self) -> &'static str

Return the 4-character family prefix (e.g., CBKD) for this error code.

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> ErrorCode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ErrorCode

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ErrorCode, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for ErrorCode

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ErrorCode

Source§

fn eq(&self, other: &ErrorCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ErrorCode

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for ErrorCode

Source§

impl Eq for ErrorCode

Source§

impl StructuralPartialEq for ErrorCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,