Skip to content

except exception raises same exception #86

@echedey-ls

Description

@echedey-ls

If it's hard to read this title, imagine the traceback of that code. Pun aside, I think making sure exceptions tracebacks are clear should be a priority.

Currently (searched for except ImportError):

  • \solposx\src\solposx\solarposition\sg2.py
    287,5: except ImportError: # pragma: no cover
  • \solposx\src\solposx\solarposition\skyfield.py
    49,5: except ImportError: # pragma: no cover

EDIT: also this one

  • in tools.py, lines 26 - 29:
      except TypeError:
          raise TypeError('The provided time stamps are timezone naive.'
                          'Please make the time stamps timezone aware.'
                          'See ``pandas.Timestamp.tz_localize``.')

EDIT: also in \src\solposx\solarposition\psa.py

  78,9:         except KeyError:
  79:               raise ValueError(f"unknown coefficients set: {coefficients}")

Citing this comment from an schizophrenic a while ago: pvlib/pvlib-python#2498 (comment)

This is the conflicting pattern, took from this repo:

    try:
        # Try loading optional package
        import sg2 as sg2_package
    except ImportError:  # pragma: no cover
        # Raise an error if package is not available
        raise ImportError(
            'The sg2_c function requires the sg2 Python package.'
            )  # pragma: no cover

Raises two exceptions, whose message does not look related:

Traceback (most recent call last):
  File "<stdin>", line 4, in fail
ModuleNotFoundError: No module named 'sg2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 7, in fail
ImportError: The sg2_c function requires the sg2 Python package.

Note, this is in a console. You'd usually have more text related to the call stack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions