Skip to content

Commit 1456059

Browse files
authored
Merge pull request #116 from omarkohl/master
Document intended differences between WithHint and WithDetail (#114)
2 parents a95e895 + 9fb13b8 commit 1456059

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ return errors.Wrap(foo(), "foo")
209209
- how to access the detail: `Error()`, regular Go formatting, Sentry Report.
210210

211211
- `WithDetail(error, string) error`, `WithDetailf(error, string, ...interface{}) error`, user-facing detail with contextual information.
212-
- **when to use: need to embark a message string to output when the error is presented to a human.**
212+
- **when to use: need to embark a message string to output when the error is presented to a developer.**
213213
- what it does: captures detail strings.
214214
- how to access the detail: `errors.GetAllDetails()`, `errors.FlattenDetails()` (all details are preserved), format with `%+v`. Not included in Sentry reports.
215215

216216
- `WithHint(error, string) error`, `WithHintf(error, string, ...interface{}) error`: user-facing detail with suggestion for action to take.
217-
- **when to use: need to embark a message string to output when the error is presented to a human.**
217+
- **when to use: need to embark a message string to output when the error is presented to an end user.**
218218
- what it does: captures hint strings.
219219
- how to access the detail: `errors.GetAllHints()`, `errors.FlattenHints()` (hints are de-duplicated), format with `%+v`. Not included in Sentry reports.
220220

hintdetail/hintdetail.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
// WithHint decorates an error with a textual hint.
2525
// The hint may contain PII and thus will not reportable.
26+
// The suggested use case for hint is to relay information to end users.
2627
//
2728
// Hint is shown:
2829
// - when formatting with `%+v`.
@@ -97,10 +98,12 @@ type ErrorHinter interface {
9798

9899
// WithDetail decorates an error with a textual detail.
99100
// The detail may contain PII and thus will not reportable.
101+
// The suggested use case for detail is to augment errors with information
102+
// useful for debugging.
100103
//
101104
// Detail is shown:
102105
// - when formatting with `%+v`.
103-
// - with `GetAllHints()` / `FlattenHints()` below.
106+
// - with `GetAllDetails()` / `FlattenDetails()` below.
104107
//
105108
// Note: the detail does not appear in the main error message returned
106109
// with Error(). Use GetAllDetails() or FlattenDetails() to retrieve

hintdetail_api.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type ErrorDetailer = hintdetail.ErrorDetailer
2727

2828
// WithHint decorates an error with a textual hint.
2929
// The hint may contain PII and thus will not reportable.
30+
// The suggested use case for hint is to relay information to end users.
3031
//
3132
// Hint is shown:
3233
// - when formatting with `%+v`.
@@ -44,10 +45,12 @@ func WithHintf(err error, format string, args ...interface{}) error {
4445

4546
// WithDetail decorates an error with a textual detail.
4647
// The detail may contain PII and thus will not reportable.
48+
// The suggested use case for detail is to augment errors with information
49+
// useful for debugging.
4750
//
4851
// Detail is shown:
4952
// - when formatting with `%+v`.
50-
// - with `GetAllHints()` / `FlattenHints()` below.
53+
// - with `GetAllDetails()` / `FlattenDetails()` below.
5154
//
5255
// Note: the detail does not appear in the main error message returned
5356
// with Error(). Use GetAllDetails() or FlattenDetails() to retrieve

0 commit comments

Comments
 (0)