Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: write errors/warnings to stderr rather than stdout #651

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
sm3142 marked this conversation as resolved.
Show resolved Hide resolved
}
}()
newType := reflect.StructOf(fields)
Expand Down
Loading