Repository navigation
core: keep the NSError domain - #20
Merged
Merged
Conversation
NSError kept the code and localized description of an error but not its domain. The code means little without it, because CoreBluetooth reuses the same numbers across domains: 4 is an invalid ATT PDU in CBATTErrorDomain and out of space in CBErrorDomain, and 15 is insufficient encryption in one and encryption timed out in the other. Carry the domain through bt_error and add NSError.Domain.
deadprogram
approved these changes
Oct 9, 2026
deadprogram
left a comment
Member
There was a problem hiding this comment.
Thank you. This is needed for tinygo-org/bluetooth#499.
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.
NSError kept the code and localized description of an error but not its domain. CoreBluetooth reuses the same numbers across domains, so the code can't be interpreted without it: 4 is an invalid ATT PDU in CBATTErrorDomain and out of space in CBErrorDomain.
This carries the domain through bt_error and adds NSError.Domain.
Needed for tinygo-org/bluetooth#498, so the darwin backend can return ATT errors as AttributeProtocolError.
Tested on macOS 15.7.7 against an ESP32-S3 peripheral. A write the peripheral rejects with Invalid PDU now reports domain CBATTErrorDomain and code 4. go build and go vet pass.