Skip to content

Commit 097ff6f

Browse files
committed
docs: explain root error handler behavior
Made-with: Cursor
1 parent 811df1e commit 097ff6f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

cmd/root.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,21 @@ func Execute(m Metadata) {
205205
fang.WithCommit(metadata.Commit),
206206
fang.WithErrorHandler(func(w io.Writer, styles fang.Styles, err error) {
207207
err = util.CleanedUpSdkError{Err: err}
208+
209+
// Some subcommands intentionally suppress diagnostics for curl-like
210+
// quiet modes while still returning a non-zero exit status.
208211
var silent interface{ Silent() bool }
209212
if errors.As(err, &silent) && silent.Silent() {
210213
return
211214
}
215+
212216
// remove margins so that it matches other pterm.error "style"
213217
// we should add them back later as it looks cleaner
214218
errorTextStyle := styles.ErrorText.UnsetMargins()
219+
220+
// Fang passes the destination for errors (normally stderr). pterm's
221+
// global Error printer does not know about it, so temporarily point
222+
// pterm at fang's writer for this handler invocation.
215223
oldErrorWriter := pterm.Error.Writer
216224
pterm.Error.Writer = w
217225
defer func() {

0 commit comments

Comments
 (0)