Skip to content

Error class naming and hierarchy divergence: core NotFound vs SDK NotFoundError, and OrderNotFound/MarketNotFound/EventNotFound inheritance chain #1410

Description

@realfishsam

Gap

Two related divergences between the core error hierarchy and both SDK error hierarchies:

1. Class name: Core exports NotFound; both SDKs export NotFoundError.

2. Inheritance chain: In core, OrderNotFound, MarketNotFound, and EventNotFound extend BaseError directly — NOT NotFound. In both SDKs, those three classes extend NotFoundError. This means instanceof NotFound in core does not catch OrderNotFound/MarketNotFound/EventNotFound, but isinstance(e, NotFoundError) in both SDKs does catch all three.

Core

core/src/errors.ts:72

export class NotFound extends BaseError {
    constructor(message: string, exchange?: string) {
        super(message, 404, 'NOT_FOUND', false, exchange);
    }
}

export class OrderNotFound extends BaseError { ... }   // extends BaseError, NOT NotFound
export class MarketNotFound extends BaseError { ... }  // extends BaseError, NOT NotFound
export class EventNotFound extends BaseError { ... }   // extends BaseError, NOT NotFound

instanceof NotFound catches only generic 404s; the three typed subclasses are siblings under BaseError, not children of NotFound.

TypeScript SDK

sdks/typescript/pmxt/errors.ts:51,57,63,69

export class NotFoundError extends PmxtError { ... }      // renamed

export class OrderNotFound extends NotFoundError { ... }   // child of NotFoundError
export class MarketNotFound extends NotFoundError { ... }  // child of NotFoundError
export class EventNotFound extends NotFoundError { ... }   // child of NotFoundError
  • Class exported as NotFoundError, not NotFound.
  • All three typed subclasses extend NotFoundError, not PmxtError directly.
  • e instanceof NotFoundError catches OrderNotFound, MarketNotFound, EventNotFound.

Python SDK

sdks/python/pmxt/errors.py:51,56,66,76

class NotFoundError(PmxtError): ...       # renamed

class OrderNotFound(NotFoundError): ...   # child of NotFoundError
class MarketNotFound(NotFoundError): ...  # child of NotFoundError
class EventNotFound(NotFoundError): ...   # child of NotFoundError

Same divergences as the TypeScript SDK.

Evidence

# Core uses NotFound
grep -n "class NotFound\b" core/src/errors.ts
# → line 72: export class NotFound extends BaseError

# Core typed subclasses extend BaseError directly
grep -n "class OrderNotFound\|class MarketNotFound\|class EventNotFound" core/src/errors.ts
# → extends BaseError (not NotFound)

# Both SDKs use NotFoundError
grep -rn "class NotFoundError\|class OrderNotFound\|class MarketNotFound\|class EventNotFound" \
    sdks/typescript/pmxt/errors.ts sdks/python/pmxt/errors.py
# → TS: NotFoundError, OrderNotFound/MarketNotFound/EventNotFound extend NotFoundError
# → Py: same pattern

Impact

  1. Class name mismatch: Any documentation, example, or user code written against the core that catches pmxt.NotFound will not compile/resolve against the SDK exports — the SDK only exports NotFoundError. Users porting code from core to SDK (or vice versa) must rename every catch clause.

  2. Hierarchy mismatch: Code running against the core that writes catch (e) { if (e instanceof NotFound) { ... } } expecting to catch order/market/event not-found errors will silently miss them, because in core those classes extend BaseError directly. The same guard written against the SDKs works correctly. This creates subtly different runtime semantics between environments.


Found by automated Core-to-SDK surface coverage audit

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-sdk-gapCore engine capabilities not exposed in SDKs

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions