Skip to content

Commit

Permalink
fix: write error messages to stderr rather than stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
sm3142 committed Nov 13, 2024
1 parent bea7c1a commit 1c5a71d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/http"
"os"
)

// ErrorDetailer returns error details for responses & debugging. This enables
Expand Down Expand Up @@ -264,7 +265,7 @@ func WriteErr(api API, ctx Context, status int, msg string, errs ...error) error
writeErr := writeResponse(api, ctx, status, "", err)
if writeErr != nil {
// If we can't write the error, log it so we know what happened.
fmt.Printf("could not write error: %s\n", writeErr)
fmt.Fprintf(os.Stderr, "could not write error: %s\n", writeErr)
}
return writeErr
}
Expand Down
3 changes: 2 additions & 1 deletion transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package huma
import (
"bytes"
"fmt"
"os"
"path"
"reflect"
)
Expand Down Expand Up @@ -132,7 +133,7 @@ func (t *SchemaLinkTransformer) OnAddOperation(oapi *OpenAPI, op *Operation) {
// Catch some scenarios that just aren't supported in Go at the
// moment. Logs an error so people know what's going on.
// https://github.com/danielgtaylor/huma/issues/371
fmt.Println("Warning: unable to create schema link for type", typ, ":", r)
fmt.Fprintln(os.Stderr, "Warning: unable to create schema link for type", typ, ":", r)
}
}()
newType := reflect.StructOf(fields)
Expand Down

0 comments on commit 1c5a71d

Please sign in to comment.