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

Improve error messages #245

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions switchboard/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ def add_tcp_intf(self, intf, intf_def, uri):
else:
for key, val in self.tcp_intfs[tcp_intfs_key].items():
if key not in ['inputs', 'outputs']:
assert val == tcp_kwargs[key]
if val != tcp_kwargs[key]:
raise ValueError(f'Mismatch on TCP interface property "{key}".'
f' New value of property is "{tcp_kwargs[key]}"'
f' but it was previously set to "{val}".')

tcp_intf = self.tcp_intfs[tcp_intfs_key]

Expand Down Expand Up @@ -616,12 +619,17 @@ def register_uri(self, type, uri, fresh=True):
else:
uris = [uri]

assert self.uri_set.isdisjoint(uris)
uris = set(uris)
intersection = self.uri_set.intersection(uris)

if len(intersection) > 0:
raise ValueError('Failed to add the following URI(s) that'
f' are already in use: {list(intersection)}')

self.uri_set.update(uris)

if fresh:
delete_queues(uris)
delete_queues(list(uris))

def make_dut(self, *args, **kwargs):
# argument customizations
Expand Down