Skip to content

Breaking: Switch to throwing DeviceError when not connected#104

Merged
microbit-matt-hillsdon merged 1 commit intoappsfrom
throw-not-connected
Mar 3, 2026
Merged

Breaking: Switch to throwing DeviceError when not connected#104
microbit-matt-hillsdon merged 1 commit intoappsfrom
throw-not-connected

Conversation

@microbit-matt-hillsdon
Copy link
Contributor

Introduce a new code for the purpose.

Previously we returned undefined in scenarios where you call the method either before connection or when unexpectedly disconnected. This can lead to errors being ignored or knock-on errors because you "know" you're connected but disconnects can happen at arbitrary points. Better to require the caller to handle an error.

Introduce a new code for the purpose.

Previously we returned undefined in scenarios where you call the method either
before connection or when unexpectedly disconnected. This can lead to errors
being ignored or knock-on errors because you "know" you're connected but
disconnects can happen at arbitrary points. Better to require the caller to
handle an error.
// TODO
}
assertConnected(this.connection);
// TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to pick this up separately as there's no plan to support serial for Bluetooth, if you want to try to implement some kind of serial over UART that's best done at the application level where you can consider the limitations.

Copy link
Contributor

@microbit-grace microbit-grace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@microbit-matt-hillsdon microbit-matt-hillsdon merged commit 52a9458 into apps Mar 3, 2026
3 of 4 checks passed
@microbit-matt-hillsdon microbit-matt-hillsdon deleted the throw-not-connected branch March 3, 2026 14:51
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.

2 participants