Skip to main content

ServerErrorKind

Enum ServerErrorKind 

Source
#[non_exhaustive]
pub enum ServerErrorKind {
Show 67 variants InternalHdmError, BadRequest, BadProtocolVersion, UnauthorizedConnection, BadOperationCode, CryptographicError, SessionEncryptionError, HeaderFormatError, BadSequenceNumber, BadJsonFormat, LastReceiptArchiveEmpty, LastReceiptDifferentUser, GenericPrintError, PrinterInitError, PrinterOutOfPaper, BadOperatorPassword, NoSuchOperator, InactiveOperator, GenericLoginPrintError, NoSuchDepartment, PaidLessThanTotal, AmountExceedsLimit, AmountMustBePositive, HdmSyncRequired, SyncIncomplete, BadReturnReceiptNumber, ReceiptAlreadyReturned, NonPositiveProductPrice, DiscountPercentOutOfRange, BadProductCode, BadProductName, EmptyProductUnit, CashlessPaymentFailure, ZeroProductPrice, FinalPriceCalculationError, CardAmountExceedsTotal, CardAmountCoversAllCashRedundant, ReportFiltersError, ReportTimeRangeError, InvalidItemPrice, WrongReceiptType, InvalidDiscountType, ReturnReceiptNotFound, BadReturnReceiptRegNum, LastReceiptNotFound, ReturnNotSupportedForType, AmountCannotBeReturned, PartialMustBeReturnedInFull, FullReturnExceedsAmount, BadReturnProductQuantity, ReturnReceiptIsReturn, BadAtgCode, InvalidPrepaymentReturn, PartialReturnSyncRequired, BadPrepaymentAmount, BadPrepaymentList, BadAmounts, BadRounding, PaymentUnavailable, NonPositiveCashAmount, AtgCodeRequired, BadPartnerTinFormat, EmarksNotAllowedInPrepayment, BadEmarkFormat, OtherUnknownError, Vendor(VendorErrorKind), Unknown(u16),
}
Expand description

Categorised server response codes per spec §4.10.

Every documented code maps to a named variant. Codes outside the documented set become Unknown(u16) so that future spec revisions don’t break existing builds.

The variants are grouped roughly by the spec’s own categories: generic errors, login errors, receipt-print errors. Recovery semantics are exposed via Self::is_retryable, Self::requires_relogin, and Self::is_fatal_for_connection.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InternalHdmError

500 — Internal HDM error.

§

BadRequest

400 — Request error (request not processed).

§

BadProtocolVersion

402 — Bad protocol version.

§

UnauthorizedConnection

403 — Unauthorised connection (HDM-registered IP doesn’t match the caller’s).

§

BadOperationCode

404 — Bad operation code in the header.

§

CryptographicError

101 — Cryptographic encryption error.

§

SessionEncryptionError

102 — Session-key encryption error.

§

HeaderFormatError

103 — Header format error.

§

BadSequenceNumber

104 — Request sequence number error.

§

BadJsonFormat

105 — JSON format error.

§

LastReceiptArchiveEmpty

141 — Last receipt archive is empty.

§

LastReceiptDifferentUser

142 — Last receipt belongs to a different user.

§

GenericPrintError

143 — Generic print error.

§

PrinterInitError

144 — Printer initialisation error.

§

PrinterOutOfPaper

145 — Printer is out of paper.

§

BadOperatorPassword

111 — Operator password error.

§

NoSuchOperator

112 — No such operator (role mismatch, inactive user, or not registered).

§

InactiveOperator

113 — Operator is inactive.

§

GenericLoginPrintError

121 — Print error (during login flow).

§

NoSuchDepartment

151 — No such department (or operator lacks access).

§

PaidLessThanTotal

152 — Paid amount is less than the total.

§

AmountExceedsLimit

153 — Receipt amount exceeds the configured limit.

§

AmountMustBePositive

154 — Receipt amount must be positive.

§

HdmSyncRequired

155 — HDM synchronisation required before this operation can succeed.

§

SyncIncomplete

156 — Synchronisation not completed.

§

BadReturnReceiptNumber

157 — Bad return-receipt number.

§

ReceiptAlreadyReturned

158 — Receipt already returned.

§

NonPositiveProductPrice

159 — Non-positive product price or quantity.

§

DiscountPercentOutOfRange

160 — Discount percent out of range (must be 0..100).

§

BadProductCode

161 — Bad product code.

§

BadProductName

162 — Bad product name.

§

EmptyProductUnit

163 — Empty product unit-of-measure.

§

CashlessPaymentFailure

164 — Cashless payment failure.

§

ZeroProductPrice

165 — Product price cannot be zero.

§

FinalPriceCalculationError

166 — Final price calculation error.

§

CardAmountExceedsTotal

167 — Card amount is greater than the receipt’s total.

§

CardAmountCoversAllCashRedundant

168 — Card amount covers the total (cash amount is redundant).

§

ReportFiltersError

169 — Fiscal-report filter conflict (more than one filter sent).

§

ReportTimeRangeError

170 — Fiscal-report time range exceeds 2 months.

§

InvalidItemPrice

171 — Invalid item price value.

§

WrongReceiptType

172 — Wrong receipt type (not product/simple/prepayment).

§

InvalidDiscountType

173 — Invalid discount type.

§

ReturnReceiptNotFound

174 — Return-target receipt does not exist.

§

BadReturnReceiptRegNum

175 — Bad registration number on the return-target receipt.

§

LastReceiptNotFound

176 — Last receipt does not exist.

§

ReturnNotSupportedForType

177 — Return not supported for this receipt type.

§

AmountCannotBeReturned

178 — Requested return amount cannot be processed.

§

PartialMustBeReturnedInFull

179 — Partial-payment receipt must be returned in full.

§

FullReturnExceedsAmount

180 — Full-return amount exceeds available.

§

BadReturnProductQuantity

181 — Bad return-product quantity.

§

ReturnReceiptIsReturn

182 — Return receipt is itself a return-type receipt.

§

BadAtgCode

183 — Bad ATG/ADG code (see taxservice.am for the canonical list).

§

InvalidPrepaymentReturn

184 — Inappropriate prepayment-return request.

§

PartialReturnSyncRequired

185 — Cannot return partial-payment receipt; HDM software sync required.

§

BadPrepaymentAmount

186 — Bad amount in prepayment case.

§

BadPrepaymentList

187 — Bad list in prepayment case.

§

BadAmounts

188 — Bad amounts in general.

§

BadRounding

189 — Bad rounding.

§

PaymentUnavailable

190 — Payment not available.

§

NonPositiveCashAmount

191 — Cash in/out amount must be greater than zero.

§

AtgCodeRequired

192 — ATG code is mandatory.

§

BadPartnerTinFormat

193 — Bad partner-TIN format.

§

EmarksNotAllowedInPrepayment

194 — eMark codes not allowed in prepayment receipts.

§

BadEmarkFormat

195 — Bad eMark code format.

§

OtherUnknownError

196 — Other unknown error documented by the spec.

§

Vendor(VendorErrorKind)

A vendor/firmware-specific code that is not part of the SRC spec §4.10. Kept in its own VendorErrorKind enum so spec codes and vendor extensions never blur together; the two sets are joined only here and in Self::from_code.

§

Unknown(u16)

Response code present in neither spec v0.7.3 nor the known vendor set. Carried verbatim for forward compatibility.

Implementations§

Source§

impl ServerErrorKind

Source

pub const fn from_code(code: u16) -> Self

Map a numeric response code to its categorised variant.

Source

pub const fn code(self) -> u16

Reverse mapping back to the numeric code.

Source

pub const fn is_retryable(self) -> bool

Whether retrying the same operation might succeed without changing state.

Conservatively false for most variants. True only for transient conditions (printer-out-of-paper, sync-incomplete, or the HDM’s UI being momentarily busy) where the situation may clear itself between attempts.

Source

pub const fn requires_relogin(self) -> bool

Whether the client should call crate::Client::login again before the next operation.

True for session-key invalidation, expired credentials, and operator-state changes detected mid-session.

Source

pub const fn is_fatal_for_connection(self) -> bool

Whether the underlying TCP connection should be closed and re-opened.

Aligned with the “Stops the server connection” column of spec §4.10.

Trait Implementations§

Source§

impl Clone for ServerErrorKind

Source§

fn clone(&self) -> ServerErrorKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ServerErrorKind

Source§

impl Debug for ServerErrorKind

Source§

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

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

impl Eq for ServerErrorKind

Source§

impl PartialEq for ServerErrorKind

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for ServerErrorKind

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.