Skip to content

Commit

Permalink
fix: capture warning to show the ROADM uid
Browse files Browse the repository at this point in the history
Signed-off-by: EstherLerouzic <[email protected]>
Change-Id: Ie13bf4c3436a5a0b8ec730698920eee2c7fb81e8
  • Loading branch information
EstherLerouzic committed Oct 16, 2024
1 parent 0d236fd commit ae858b9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gnpy/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from collections import namedtuple
from typing import Union
from logging import getLogger
import warnings

from gnpy.core.utils import lin2db, db2lin, arrange_frequencies, snr_sum, per_label_average, pretty_summary_print, \
watt2dbm, psd2powerdbm, calculate_absolute_min_or_zero
Expand Down Expand Up @@ -239,7 +240,11 @@ def __init__(self, *args, params=None, **kwargs):
if not params:
params = {}
try:
super().__init__(*args, params=RoadmParams(**params), **kwargs)
with warnings.catch_warnings(record=True) as caught_warnings:
super().__init__(*args, params=RoadmParams(**params), **kwargs)
if caught_warnings:
msg = f'In ROADM {kwargs["uid"]}: {caught_warnings[0].message}'
_logger.warning(msg)
except ParametersError as e:
msg = f'Config error in {kwargs["uid"]}: {e}'
raise ParametersError(msg) from e
Expand Down

0 comments on commit ae858b9

Please sign in to comment.