Skip to content

Make target-specific errors private#562

Merged
newpavlov merged 1 commit intomasterfrom
private_errors
Dec 11, 2024
Merged

Make target-specific errors private#562
newpavlov merged 1 commit intomasterfrom
private_errors

Conversation

@newpavlov
Copy link
Copy Markdown
Member

@newpavlov newpavlov commented Dec 9, 2024

The main reason for existence of the target-specific errors is nicer error descriptions. Users arguably should not match on those error constants since our inner implementation may change together with possible error codes (for example, like with IOS_SEC_RANDOM). Marking the error constants as private we get flexibility to change error codes and names.

Additionally, the internal_desc change reduces generated binary size since compiler no longer has to include irrelevant error descriptions. Ideally the target-specific error descriptions would be defined in the relevant modules, but I couldn't find a good way to do it, so, unfortunately, I had to partially duplicate backend cfgs in internal_desc.

@newpavlov newpavlov requested a review from josephlr December 9, 2024 16:45
@newpavlov newpavlov marked this pull request as ready for review December 9, 2024 16:45
Copy link
Copy Markdown
Member

@josephlr josephlr left a comment

Choose a reason for hiding this comment

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

This looks good and removes confusing stuff from the public API. I was also trying to figure out ways to put the descriptions in the platform-specific files, but I also don't know how to do this.

I'll keep thinking about it, but you should merge this in the meantime.

@newpavlov newpavlov merged commit 83bef12 into master Dec 11, 2024
@newpavlov newpavlov deleted the private_errors branch December 11, 2024 07:59
takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
The main reason for existence of the target-specific errors is nicer
error descriptions. Users arguably should not match on those error
constants since our inner implementation may change together with
possible error codes (for example, like with `IOS_SEC_RANDOM`). Marking
the error constants as private we get flexibility to change error codes
and names.

Additionally, the `internal_desc` change reduces generated binary size
since compiler no longer has to include irrelevant error descriptions.
Ideally the target-specific error descriptions would be defined in the
relevant modules, but I couldn't find a good way to do it, so,
unfortunately, I had to partially duplicate backend `cfg`s in
`internal_desc`.
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