Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Custom exception handling makes troubleshooting difficult #115

Copy link
Copy link
@bessman

Description

@bessman
Issue body actions

Throughout PSL, this is a common pattern:

try:
    <do something>
except Exception as ex:
    self.raiseException(ex, "Communication Error , Function : " + inspect.currentframe().f_code.co_name)

This makes troubleshooting difficult for several reasons:

  1. First and foremost, self.raiseException is not python3-compatible, so anytime it is called the original error is lost and an unrelated AttributeError is raised instead.
  2. self.raiseException is called from within classes which do not implement it (for example), which again loses the original exception and raises an unrelated one.

Even if the two above bugs are addressed, this type of custom exception handling reduces the amount of information normally available.

  1. Information on what happened is lost, since the exception type degenerates to a generic RuntimeError.
  2. Information on where it happened is lost, since every error is raised on line 4107 of sciencelab.py, instead of whereever the original exception was raised.
  3. It can inject false information about what happened. In the above try-except block, every exception is reported as "Communication Error", even though the except catches all exceptions, not just communication related ones.
  4. It increases cyclomatic complexity, making the code harder to understand and harder to unit test.

Python has excellent built-in exception handling, and as far as I can see PSL's custom implementation offers no advantages over it. What is its purpose?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.