feat: add shared BB.Error.Invalid.Bridge.* error modules#159
Open
jimsynz wants to merge 1 commit into
Open
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #145 (the core half).
Problem
bb_servo_feetechandbb_servo_robotiseach define the same four fully-qualified error modules in theBB.Error.*namespace, whichbbcore owns:BB.Error.Invalid.Bridge.InvalidParamIdBB.Error.Invalid.Bridge.ReadOnlyBB.Error.Invalid.Bridge.TorqueMustBeDisabledBB.Error.Invalid.Bridge.UnknownParamThe 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
bbcore (issue option 1):lib/bb/error/invalid/bridge/, byte-equivalent to the drivers' versions with hardware-neutral doc wording (no Feetech/Dynamixel specifics). Fields andmessage/1output are unchanged, so they're drop-in for the existingalias BB.Error.Invalid.Bridge.*usages.BB.Error.Invalid.Bridgenamespace module, matching the existingBB.Error.Hardware/BB.Error.Invalidnamespace-module pattern.test/bb/error/invalid/bridge_test.exscovering 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_feetechandbb_servo_robotiswill delete their local copies (theirbridge.ex/bridge_test.exsalready reference these by full name viaalias, so no other changes). That's what actually removes the collision; this PR is the prerequisite.mix check --no-retrypasses locally (compiler, credo, dialyzer, ex_doc, ex_unit, formatter, mix_audit, reuse, spark_formatter, spark_cheat_sheets, unused_deps).