Skip to content

Add more standardized error definitions #365

Open

Description

@joy4eg

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?

return Certificate{}, fmt.Errorf("no certificate available for '%s'", name)

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") { ... } 

Activity

  1. francislavoie commented on Jan 12, 2026

    @francislavoie
    Member

    Seems reasonable, PRs welcome if you want to introduce this

  2. mholt commented on Jan 12, 2026

    @mholt
    Member

    Yeah, I agree. Sounds good to me if you want to submit a PR with your specific suggestions that work for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestRequest for new feature or functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions