Sha256: c8cad475439d6482dc8e92265f9073bf4629c03417ee1f85e0594ee8c8c9b967

Contents?: true

Size: 530 Bytes

Versions: 104

Compression:

Stored size: 530 Bytes

Contents

def handle_error_by_throwing_exception():
    raise Exception("Meaningful message describing the source of the error")


def handle_error_by_returning_none(input_data):
    try:
        return int(input_data)
    except ValueError:
        return None


def handle_error_by_returning_tuple(input_data):
    try:
        return (True, int(input_data))
    except ValueError:
        return (False, None)


def filelike_objects_are_closed_on_exception(filelike_object):
    with filelike_object as fobj:
        fobj.do_something()

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.97 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.96 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.95 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.94 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.93 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.92 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.91 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.90 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.89 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.88 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.87 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.86 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.85 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.84 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.83 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.82 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.81 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.80 tracks/python/exercises/error-handling/example.py
trackler-2.2.1.79 tracks/python/exercises/error-handling/example.py