pygomx/mxsmal/src/pymxutils/mxutils/click.py

20 lines
455 B
Python
Raw Normal View History

2026-03-17 10:21:52 +01:00
# Copyright (C) 2026 saces@c-base.org
# SPDX-License-Identifier: AGPL-3.0-only
from functools import partial, wraps
import click
def click_catch_exception(func=None, *, handle):
if not func:
return partial(click_catch_exception, handle=handle)
@wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except handle as e:
raise click.ClickException(e)
return wrapper