epanet-python icon indicating copy to clipboard operation
epanet-python copied to clipboard

Could there be any methods to analyses the warning throws?

Open LittleBrize opened this issue 4 years ago • 1 comments

When I was using the python version of OWA-EPANET, I found all functions do not retrieve the integer values of warnings, as it's stated in "README". You know it's hard to check these basically identical warnings. Could there be any methods to analyses the warning throws?

LittleBrize avatar Jul 16 '21 08:07 LittleBrize

I see a couple of options here. First off, the relevant piece of SWIG wrapper is here: https://github.com/OpenWaterAnalytics/epanet-python/blob/f492d414dbeef73cd7366db0f51855b6fd1a14de/owa-epanet/wrapper/toolkit.i#L123

... so EPANET has returned a non-zero (but less than 10) code, which indicates a warning. Our SWIG wrapper is inspecting the code and issuing the warning, so we could either:

  • format the numerical code into the warning string,
  • increase the stack_level parameter to give the user more insight into the wrapped function that generated the warning,
  • create a custom warning class that would contain the EPANET integer code as an instance variable

Any of these options would be a pretty minor tweak to the wrapper, but I list them here in case others have better ideas...

samhatchett avatar Jul 16 '21 12:07 samhatchett