Skip to content

Redirect sqlcmd errors to err stream #143

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

Merged
merged 4 commits into from
Oct 6, 2022
Merged

Conversation

apoorvdeshmukh
Copy link
Contributor

@apoorvdeshmukh apoorvdeshmukh commented Oct 6, 2022

By default sqlcmd uses stdout as the default stream for output and errors.
As a result when the stderr is redirected externally to file, the sqlcmd errors are missed.
This commit logs all the sqlcmd errors to the stderr of OS in case default output
stream is stdout and stderr for sqlcmd is not set.
Resolves #105

@@ -209,6 +209,19 @@ func (s *Sqlcmd) SetError(e io.WriteCloser) {
s.err = e
}

// WriteError writes the error on specified stream
func (s *Sqlcmd) WriteError(stream io.Writer, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the consolidation into this function

Copy link
Collaborator

@shueybubbles shueybubbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

Copy link
Collaborator

@shueybubbles shueybubbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@apoorvdeshmukh apoorvdeshmukh merged commit cbf535e into main Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors for :R are thrown on stdout instead of stderr
2 participants