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

target: improve exceptions #1270

Conversation

Bastian-Krause
Copy link
Member

Description
Use short-hand class names and add driver causing NoSupplierFoundErrors in error messages.

Checklist

  • PR has been tested (tested, but did not trigger all exception code paths)

labgrid's exceptions are already hard to understand, so at least use the
short-hand version of the class name in the error messages.

Example:

  NoDriverFoundError: multiple drivers matching <class 'labgrid.protocol.consoleprotocol.ConsoleProtocol'> found in Target(name='main', env=Environment(config_file='env.yaml')) with the same priorities

..becomes..

  NoDriverFoundError: multiple drivers matching ConsoleProtocol found in Target(name='main', env=Environment(config_file='env.yaml')) with the same priorities

Signed-off-by: Bastian Krause <[email protected]>
NoSupplierFoundError and its sub classes are hard to understand if the
driver/strategy causing it is not mentioned:

  NoDriverFoundError: multiple drivers matching ConsoleProtocol found in Target(name='main', env=Environment(config_file='env.yaml')) with the same priorities

Improve this by rasing a more detailed exception from the original
exception with this information included:

  NoDriverFoundError: binding MyStrategy failed: multiple drivers matching ConsoleProtocol found in Target(name='main', env=Environment(config_file='env.yaml')) with the same priorities

Signed-off-by: Bastian Krause <[email protected]>
@codecov
Copy link

codecov bot commented Sep 17, 2023

Codecov Report

Patch coverage: 100.0% and no project coverage change.

Comparison is base (2dcc631) 63.0% compared to head (ca2b88d) 63.0%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1270   +/-   ##
======================================
  Coverage    63.0%   63.0%           
======================================
  Files         160     160           
  Lines       11848   11851    +3     
======================================
+ Hits         7472    7476    +4     
+ Misses       4376    4375    -1     
Files Changed Coverage Δ
labgrid/target.py 92.1% <100.0%> (+<0.1%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@cruise-bryan-murdock cruise-bryan-murdock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it will be much more helpful

@Bastian-Krause Bastian-Krause added this to the v23.1 milestone Oct 11, 2023
@Bastian-Krause
Copy link
Member Author

Since this changes the exception string only and the PR is open for a while now, I'll merge this without second approval.

@Bastian-Krause Bastian-Krause merged commit 7e74c8c into labgrid-project:master Nov 10, 2023
9 checks passed
@Bastian-Krause Bastian-Krause deleted the bst/improve-target-exceptions branch November 10, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants