You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary
I'm using wntr to develop a plugin for QGIS. I'm doing a check to avoid simulation errors. My goal is to display a message with the error code when I try to simulate a network with an error. My goal is to get just an error message informing the code, without generating the error. Is there any documentation or examples that work with this? Error messages or how to get the error code.
Example
Using this simple script and simulating a network with error, I get the error and the following message: wntr.epanet.toolkit.EpanetException: EPANET Error 110
The following example will print the EPANET error code
import wntr
# Create a water network model
inp_file = "networks/Net3.inp"
wn = wntr.network.WaterNetworkModel(inp_file)
# Add an invalid value to wn so that the simulation fails
link = wn.get_link('123')
link.diameter = -1
# Run the simulation in a try:except block and print the error message
try:
sim = wntr.sim.EpanetSimulator(wn)
results = sim.run_sim()
pressure = results.node['pressure']
except Exception as e:
print(e)
Summary
I'm using wntr to develop a plugin for QGIS. I'm doing a check to avoid simulation errors. My goal is to display a message with the error code when I try to simulate a network with an error. My goal is to get just an error message informing the code, without generating the error. Is there any documentation or examples that work with this? Error messages or how to get the error code.
Example
Using this simple script and simulating a network with error, I get the error and the following message: wntr.epanet.toolkit.EpanetException: EPANET Error 110
Is there any way to obtain, in cases of simulation error, only the message with the error code, without generating the simulation error?
The text was updated successfully, but these errors were encountered: