Skip to content

feat: add shared BB.Error.Invalid.Bridge.* error modules#159

Open
jimsynz wants to merge 1 commit into
mainfrom
feat/bridge-error-modules
Open

feat: add shared BB.Error.Invalid.Bridge.* error modules#159
jimsynz wants to merge 1 commit into
mainfrom
feat/bridge-error-modules

Conversation

@jimsynz

@jimsynz jimsynz commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Addresses #145 (the core half).

Problem

bb_servo_feetech and bb_servo_robotis each define the same four fully-qualified error modules in the BB.Error.* namespace, which bb core owns:

  • BB.Error.Invalid.Bridge.InvalidParamId
  • BB.Error.Invalid.Bridge.ReadOnly
  • BB.Error.Invalid.Bridge.TorqueMustBeDisabled
  • BB.Error.Invalid.Bridge.UnknownParam

The definitions are identical apart from copyright year and a couple of words of doc wording. In a mixed-hardware robot (Feetech bus + Dynamixel bus) both deps load into one application; the BEAM keeps whichever compiles last, emits a "redefining module" warning, and silently discards the other — making any doc-string-sensitive match load-order dependent.

Change

Move the canonical definitions into bb core (issue option 1):

  • Adds the four modules under lib/bb/error/invalid/bridge/, byte-equivalent to the drivers' versions with hardware-neutral doc wording (no Feetech/Dynamixel specifics). Fields and message/1 output are unchanged, so they're drop-in for the existing alias BB.Error.Invalid.Bridge.* usages.
  • Adds a BB.Error.Invalid.Bridge namespace module, matching the existing BB.Error.Hardware / BB.Error.Invalid namespace-module pattern.
  • Adds test/bb/error/invalid/bridge_test.exs covering fields, severity, and message formatting for each.

No registry wiring is needed — use BB.Error (→ use Splode.Error, class: :invalid) is self-contained.

Follow-up

Once this is released to hex, bb_servo_feetech and bb_servo_robotis will delete their local copies (their bridge.ex / bridge_test.exs already reference these by full name via alias, so no other changes). That's what actually removes the collision; this PR is the prerequisite.

mix check --no-retry passes locally (compiler, credo, dialyzer, ex_doc, ex_unit, formatter, mix_audit, reuse, spark_formatter, spark_cheat_sheets, unused_deps).

`bb_servo_feetech` and `bb_servo_robotis` each defined the same four
`BB.Error.Invalid.Bridge.*` modules — a namespace `bb` core owns. In a
mixed-hardware robot that pulls both deps, the BEAM loads whichever
compiles last, warns "redefining module", and silently discards the
other, making any doc-string-sensitive match load-order dependent.

Move the canonical definitions into core so every bridge driver shares
one set: `InvalidParamId`, `ReadOnly`, `TorqueMustBeDisabled`, and
`UnknownParam`, plus a `BB.Error.Invalid.Bridge` namespace module. Doc
wording is made hardware-neutral. The drivers will drop their local
copies and resolve these via `bb` in follow-up PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant