Optionalmessage: stringOptional human-readable reason (logged, not routed on)
Readonly__type__Runtime brand (Symbol.for — survives duplicated module instances)
Static OptionalprepareOptional override for formatting stack traces
OptionalstackStaticstackStaticcaptureCreate .stack property on a target object
OptionalconstructorOpt: FunctionStaticfromNominal constructor for a new OrderRejectedError from any thrown object. Use this
instead of instanceof to recognize instances created by a DIFFERENT copy of
this module (duplicated bundles, linked packages).
Any thrown object
a new OrderRejectedError with the original message, or a default message if the original was not a string
StaticisNominal type guard by the runtime brand. Use this instead of instanceof:
the check is based on Symbol.for, so it recognizes instances created by a
DIFFERENT copy of this module (duplicated bundles, linked packages).
Any thrown object
true when the object carries the OrderRejectedError brand
TERMINAL business rejection of an order operation — "the exchange definitively refused this order and retrying is pointless".
Where to throw it
Only from the ORDER GATES (the
onOrderSyncchannel), i.e. any of:Broker.useBrokerAdapter→onOrderOpenCommit/onOrderCloseCommit;callbacks.onOrderSync/ handlerIAction.orderSync(deprecated channel);listenSynclistener.What the framework does
The throw propagates UNWRAPPED through every layer (none of them re-wrap errors — the runtime brand survives) and resolves into the
IBrokerOrderVerdict{ reason: "rejected" }(see interfaces/Broker.interface). Consequences:onSignalPendingClose) — the REAL exchange position may still exist, and its reconciliation is the adapter's/operator's responsibility.Loudness:
errorEmitterfires (warn + console on every layer).exitEmitterdoes NOT fire — a business rejection is a normal (if unhappy) outcome, not a fatal network condition; the process keeps running. Compare with transient exhaustion, which DOES signal a fatal exit.When it is appropriate
Throw only on a CONFIRMED business impossibility reported by the exchange: no counterparty / no liquidity, symbol delisted or trading halted, min-notional / lot-size violation, account restriction — anything where repeating the same request can never succeed. Do NOT throw it on network trouble (timeout, 5xx, rate limit, lost response): throw a plain Error or OrderTransientError instead so the bounded retry machinery gets its chance.
Nuances
onOrderActiveCheck/onOrderScheduleCheck/callbacks.onOrderCheck/listenCheck) is a userspace protocol violation: it is INTENTIONALLY degraded to the "transient" verdict (counted toward CC_ORDER_CHECK_RETRY_ATTEMPTS) instead of being honored as terminal.__type__ === Symbol.for("OrderRejectedError")brand via the static guard — never byinstanceof, so it survives duplicated module instances across bundles. Any subclass or foreign copy carrying the same global symbol is recognized too.params.onOrderSyncdirectly — the client-side guard handles that path identically).messageis optional and purely informational (it ends up in warn logs and the errorEmitter payload); routing depends only on the brand.Example