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

Returning Errors rather that raising them #51

Open
rscottweekly opened this issue Dec 17, 2024 · 3 comments
Open

Returning Errors rather that raising them #51

rscottweekly opened this issue Dec 17, 2024 · 3 comments
Labels
question Further information is requested

Comments

@rscottweekly
Copy link

I'm not sure if this is deliberate but in uk_who.py, there are a few lines where errors are returned rather than raised - e.g. lines 150 & 167 - which means they don't get caught in the try-block and instead crash the programme further down.

@eatyourpeas
Copy link
Member

Thanks @rscottweekly - do you have a use case where this caused you difficulties? Might you be happy to share some details?

@eatyourpeas eatyourpeas added the question Further information is requested label Dec 17, 2024
@rscottweekly
Copy link
Author

Thanks for publishing this by the way, its made me code for a few audits so so much easier! I'm a paeds anaesthetist doing work with drug dosing for children living with obesity based on the SOBA guidelines.

The root cause of this was a bug on my end that caused it (I had transposed sex and age) in the call to sds_for_measurement.

The values called in sds_for_measurement were

age = {str} 'male'
measurement_method = {str} 'bmi'
observation_value = {float64: ()} 14.711859613504629
reference = {str} 'uk-who'
sex = {int} 1

which are obviously invalid values - the problem being they just get passed down to lms_value_array_for_measurement_for_reference and then to uk_who_lms_array_for_measurement_and_sex within try blocks, but on line 168 of that function it returns theLookupError rather than raiseing it, so was unhandled and just returns a LookupError object not the array. This means the try blocks don't catch the error and fetch_lms in sds_for_measurement is passed a LookupError object and not an array of data. When that calls nearest_lowest_index with the lms_array being in fact a LookupError object, this failed on the enumerate on line 410.

So the challenge was I was sending invalid data to sds_for_measurement but it was not erroring out til further down some deeper function calls which made it hard to debug.

Does that make sense? Am happy to do a PR if you'd like to resolve the issues?

@eatyourpeas
Copy link
Member

Thank you @rscottweekly that is great. You are right that the error handling could be better. We possibly rely too heavily on the API and server infront of all this. Yes please, very happy to look at a PR - thank you

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

No branches or pull requests

2 participants