Skip to content

Minor: Write errors to stderr instead of stdout #669

@bartolomej

Description

@bartolomej

Problem

I noticed that this error doesn't get printed to stderr:

invalid private key for account: emulator-account

After some investigation, I saw that most of the errors caught at the top level (e.g. when triggering the emulator start command) are written to stdout instead of stderr, because this utility is used:

func Exit(code int, msg string) {
fmt.Println(msg)
os.Exit(code)
}

I think that it would be nice if we write all error messages to stderr as a general practice. Some benefits of this:

  • some dev tools (like Flowser) can automatically detect errors and provide better feedback to the user
  • users running the flow emulator command, can filter error logs (e.g. flow emulator > emulator.log 2> emulator-error.log)

Steps to Reproduce

  1. Run the emulator
  2. Trigger an error (e.g. provide an invalid key in flow.json)

Acceptance Criteria

Flow-cli error logs are written to STDERR.

Context

I'm working on Flowser tool, which automatically detects errors (those logs emitted to stderr) and provides a visual feedback to the user.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions