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

Specify preprocessor for wrapped errors #36

Closed
neithere opened this issue Aug 20, 2013 · 2 comments
Closed

Specify preprocessor for wrapped errors #36

neithere opened this issue Aug 20, 2013 · 2 comments

Comments

@neithere
Copy link
Owner

Use cases:

  • every wrapped error should be printed in red colour.
  • every wrapped error should have the prefix "ERR:".

Example code:

import termcolor

def format_error(excinfo):
    return termcolor.colored('ERR: {0}!'.format(excinfo), 'red')

@wrap_errors([KeyError], processor=format_error)
def func(key):
    return db[key]

Note: This issue has been automatically migrated from Bitbucket
Created by @neithere on 2013-01-14 05:54:56+00:00, last updated: 2013-01-14 06:57:17+00:00

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

Backwards compatibility notes

The old version of @wrap_errors() expects *args. It is impossible to add an optional named argument as a function with signature wrap_errors(processor=None, *errors), called as wrap_errors(KeyError), would be interpreted as wrap_errors(processor=KeyError). This is way it is now required that the first argument is an optional list.

A hack is added to maintain backward compatibility until Argh 1.0.

Argh 1.0 should be released without the hack, i.e. all code written in the old style — @wrap_errors(ExceptionClass) — will break.

A DeprecationWarning should be emitted. Release notes should contain migration guidelines.

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

@neithere
Copy link
Owner Author

Fix #36: Specify preprocessor for wrapped errors

Added hack for backwards compatibility + deprecation warning.

→ <<cset 94b2ee4c8e9d>>

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

neithere added a commit that referenced this issue Aug 20, 2013
Added hack for backwards compatibility + deprecation warning.
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