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

Fix error handling within iterator #362

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Mar 8, 2020

  1. Change logic to get out of the iterator

    When no error message needs to be passed, use 'return' to exit the
    generator as recommended in PEP-479.
    
    When an error message needs to be passed, raise a RuntimeError exception
    instead to ease the data flow. No need to catch exception in the
    iterator as we will deal globally with exceptions raised at higher
    level.
    buddly27 committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    425f8da View commit details
    Browse the repository at this point in the history
  2. Handle exception raised.

    The logic within 'util.defer' is catching all exceptions and emit it
    as a result without discriminating between finished tasks and errors.
    Therefore we could simply check if the result is an instance of
    Exception to figure out if the process should exit.
    buddly27 committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    db36ef7 View commit details
    Browse the repository at this point in the history
  3. Revert logic to use StopIteration while conforming to Python 2.7 and 3.7

    Using try-catch to transmit error messages from the iterator to the
    process callback would be nicer, but some issues remains:
    - It doesn't account for non-error messages (e.g. "Stopped")
    - It doesn't discriminate between error which should be caught and error
      which should raise.
    
    Therefore it is simpler to keep using StopIteration to exit the iterator
    while transmitting messages to display, and change the syntax to conform
    with Python 2.7 (No 'return' with argument allowed inside generators)
    and Python 3.7 (generators shouldn't raise StopIteration).
    buddly27 committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    3f17eea View commit details
    Browse the repository at this point in the history

Commits on Apr 18, 2020

  1. Configuration menu
    Copy the full SHA
    738b529 View commit details
    Browse the repository at this point in the history