caddyserver / caddyserver/certmagic
Add more standardized error definitions
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.6k
- Forks
- 354
- Avg merge
- 9d 23h
- Merged PRs (30d)
- 3
Description
It would be nice to have some predefined errors like:
var (
ErrNoCertAvailable = errors.New("no certificate available")
ErrSomethingWrong = errors.New("...")
// TBD.
)
So the client code could do:
if errors.Is(err, certmagic.ErrNoCertAvailable) { // Do something here }
So far we have some tricky logic that selects a certificate for the connection, which involves certmagic, static certificates, and some internal tools.
Having the ability to check for particular error would be really helpful.
What would you like to have changed?
Why is this feature a useful, necessary, and/or important addition to this project?
It allows checking for the specific errors via generic methods like errors.Is
What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?
if strings.Contains(err.Error(), "no certificate available") { ... }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at handshake.go around line 404 and trace the certificate-selection errors returned through certmagic and related certificate sources. Identify the stable conditions that should have predefined errors, then verify that callers can distinguish them with errors.Is. Done means the selected errors are exposed as package definitions and the relevant returned errors support those checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100