@wraps(fn)
def wrapper(catch_exception=True, **kwargs):
    if catch_exception:
        try:
            fn(**kwargs)
        except (DAGBuildError, DAGRenderError):
            error = traceback.format_exc()
            color = False
        except Exception:
            error = traceback.format_exc()
            color = True
        else:
            error = None
        if error:
            if color:
                tw = TerminalWriter(file=sys.stderr)
                tw._write_source(error.splitlines())
            else:
                print(error, file=sys.stderr)
            sys.exit(1)
    else:
        fn(**kwargs)
@wraps(fn)
def wrapper(catch_exception=True, **kwargs):
    if catch_exception:
        try:
            fn(**kwargs)
        except (DAGBuildError, DAGRenderError):
            error = traceback.format_exc()
            color = False
        except Exception:
            error = traceback.format_exc()
            color = True
        else:
            error = None
        if error:
            if color:
                tw = TerminalWriter(file=sys.stderr)
                tw._write_source(error.splitlines())
            else:
                print(error, file=sys.stderr)
            sys.exit(1)
    else:
        fn(**kwargs)