Skip to content

Conversation

@felixdivo
Copy link
Collaborator

Part of #1046.

Also publicly exposes a new exception helper error_check which was previously part of the usb2can interface.

Part of #1046.

Also publicly exposes a new exception helper: `error_check` that was previously part of the `usb2can` interface.
@felixdivo felixdivo added this to the 4.0.0 Release milestone Oct 27, 2021
@felixdivo felixdivo self-assigned this Oct 27, 2021
@mergify mergify bot requested a review from hardbyte October 27, 2021 14:41
@codecov
Copy link

codecov bot commented Oct 27, 2021

Codecov Report

Merging #1153 (a214026) into develop (beb5727) will decrease coverage by 0.02%.
The diff coverage is 76.47%.

❗ Current head a214026 differs from pull request most recent head 723d0cb. Consider uploading reports for the commit 723d0cb to get more accurate results

@@             Coverage Diff             @@
##           develop    #1153      +/-   ##
===========================================
- Coverage    70.48%   70.46%   -0.03%     
===========================================
  Files           79       79              
  Lines         7684     7688       +4     
===========================================
+ Hits          5416     5417       +1     
- Misses        2268     2271       +3     

set_bit_timing = Mock()
set_enabled = Mock()
set_monitor = Mock()
start = Mock()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was duplicated

@felixdivo
Copy link
Collaborator Author

This PR is important since I need the exception helper error_check for slcan and gs_usb.

Comment on lines +105 to +117
@contextmanager
def error_check(
error_message: Optional[str] = None,
exception_type: Type[CanError] = CanOperationError,
) -> None:
"""Catches any exceptions and turns them into the new type while preserving the stack trace."""
try:
yield
except Exception as error:
if error_message is None:
raise exception_type(str(error)) from error
else:
raise exception_type(error_message) from error
Copy link
Owner

Choose a reason for hiding this comment

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

Nice

@felixdivo felixdivo merged commit 38889ec into develop Nov 11, 2021
@felixdivo felixdivo deleted the felixdivo-issue-1046-cantact branch November 11, 2021 09:26
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.

2 participants