Skip to content

Redirect sqlcmd errors to err stream - #143

Merged
Apoorv Deshmukh (apoorvdeshmukh) merged 4 commits into
mainfrom
apoorvdeshmukh/105
Oct 6, 2022
Merged

Redirect sqlcmd errors to err stream#143
Apoorv Deshmukh (apoorvdeshmukh) merged 4 commits into
mainfrom
apoorvdeshmukh/105

Conversation

@apoorvdeshmukh

@apoorvdeshmukh Apoorv Deshmukh (apoorvdeshmukh) commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

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

Comment thread pkg/sqlcmd/sqlcmd.go Outdated
Comment thread pkg/sqlcmd/sqlcmd.go
}

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🕐

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

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