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

Wrapped errors should go to stderr #37

Closed
neithere opened this issue Aug 20, 2013 · 1 comment
Closed

Wrapped errors should go to stderr #37

neithere opened this issue Aug 20, 2013 · 1 comment

Comments

@neithere
Copy link
Owner

Use case

db = {'a': 1}

@wrap_errors([KeyError])
def func(key):
    return db[key]
$ app a
→ stdout: 1
→ stderr:

$ app b
→ stdout:
→ stderr: KeyError: 'b'

Motivation

The use case above implies that the command output may be redirected to another command or a file. Current implementation would have the following negative effect:

  1. the user will be unaware of the error;
  2. the error message will be misinterpreted as an actually retrieved value and processed, generating a further error somewhere in the toolchain.

Solution

Normal flow and catched errors should be separated in the dispatcher.

  • If an error is wrapped, the result should go to the object defined as dispatch(errors_file=sys.stderr).
  • The rest goes to the object defined as dispatch(output_file=sys.stdout).

Note: This issue has been automatically migrated from Bitbucket
Created by @neithere on 2013-01-14 10:18:47+00:00, last updated: 2013-01-30 01:06:04+00:00

@ghost ghost assigned neithere Aug 20, 2013
@neithere
Copy link
Owner Author

Fix #37: Wrapped errors should go to stderr

→ <<cset 287d146684ac>>

Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2013-01-30 01:06:04+00:00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant