Skip to content

Commit bdd7d6d

Browse files
committed
docs(golang): how a caller's fake builds a Diagnostic that matches a sentinel
1 parent dd3b708 commit bdd7d6d

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎languages/golang/internal/guest/diagnostic.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ import (
2929
// A guest built before se_last_error, or one whose error does not decode,
3030
// returns the bare sentinel instead: the detail is never allowed to hide
3131
// the failure.
32+
//
33+
// Only a guest makes a Diagnostic that unwraps to a sentinel. A fake in a
34+
// caller's test that needs both wraps the two together, and errors.Is and
35+
// errors.As each find theirs:
36+
//
37+
// d := &encrypt.Diagnostic{Code: "stack_encrypt::foreign_keyset", Message: "..."}
38+
// return fmt.Errorf("%w: %w", encrypt.ErrForeignKeyset, d)
3239
type Diagnostic struct {
3340
// Code is the error's code, "crate::name": "stack_encrypt::foreign_keyset",
3441
// "stack_kms::keyset_not_found", "stack_profile::not_found". Stable, so

0 commit comments

Comments
 (0)