nleroy917 / optipyzer

Multi-Species Codon Optimization Engine
https://optipyzer.com
Apache License 2.0
23 stars 5 forks source link

AttributeError for NoneType returns #8

Closed whitman103 closed 3 years ago

whitman103 commented 3 years ago

Relatively often, I've run across the possibility that something goes wrong with the procedure either from my end or the optimization simply does not go through and the request response is null and has NoneType. The error thrown in these situations is:

data = response.json() AttributeError: 'NoneType' object has no attribute 'json'

at line 160 in the optipyzer/api file. The exception handling currently uses a TypeError to catch these situations. Shouldn't it use an AttributeError, for clear reasons? It could be just a problem of my usage, but it is especially annoying because the mismatching errors causes a crash in the program. Let me know if I'm simply using the program incorrectly.

nleroy917 commented 3 years ago

What code are you running to achieve this?

My disclaimer will be that this is an older API I've written with even older code from many years ago, so admittedly it may be "messy" or poorly designed...

If you see the potential for improvement I GLADLY welcome any contributions, but in the meantime, could you provide the code you're running, so I can look into it a bit more?

Also: If the response object has no attribute json then the request clearly failed somewhere, which could totally be a flaw in the API or your request. But - regardless it should return why it failed.

nleroy917 commented 3 years ago

I think this got fixed in #9