Skip to content

Custom exception handling makes troubleshooting difficult #115

@bessman

Description

@bessman

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?

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy