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

Silent failures in straw/straw.py #42

Open
srcoulombe opened this issue Oct 27, 2019 · 2 comments
Open

Silent failures in straw/straw.py #42

srcoulombe opened this issue Oct 27, 2019 · 2 comments

Comments

@srcoulombe
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Some functions in straw/straw.py print a message and return -1 when unexpected outcomes are encountered. Checking for a returned value of -1 could help, but 1) this isn't currently done in the code, 2) isn't ideal as it delegates the responsibility of catching these exceptions outside of the relevant function. Worse, it can let execution carry on for a while and then trigger an unexpected and hard-to-trace exception when the -1 value is subsequently used.

Describe the solution you'd like
Explicitely raising typed exceptions with informative messages and documenting common cases for their occurrence.

Describe alternatives you've considered
None, but suggestions are encouraged.

Example

    if (magic_string != b"HIC"):
        print('This does not appear to be a HiC file magic string is incorrect')
        return -1
    global version
    version = struct.unpack('<i',req.read(4))[0]
    if (version < 6):
        print("Version {0} no longer supported".format(str(version)))
        return -1
@srcoulombe
Copy link
Contributor Author

I've got a branch that fixes these issues ready to compare. Some conflicts will be raised as it stands, so if the following could be answered, I could make the changes necessary to avoid the conflicts before merging:

  1. The "norm" parameter to straw/straw.py is no longer being checked as per 80644d9. Should invalid norm values trigger an exception statement which would print the valid norm values?

  2. Is there an incentive to maintain compatibility for python 3.<6? I'm just asking because if we can assume users will have python 3.6+, then f-strings would make some parts of the code much more legible.

@nchernia
Copy link
Contributor

nchernia commented Jan 10, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants