pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
199 stars 167 forks source link

How to avoid program crash due to value Errors #296

Closed morrison93 closed 5 years ago

morrison93 commented 5 years ago

Hey guys!

I'm new to lopy and i'm working with a lopy4/pysense node to a nano-gateway which is also a lopy4/pysense and I want to prevent the node to stop due to errors.

For example some "raise value error" in some library of the pysense, instead of crashing the pysense, i want it to pass some trash value to the payload that i'm sending.

Any clues on how to do that?

Thank you in advance

robert-hh commented 5 years ago

Have a look at the try/except structure of Python, which allows you to catch for instance a ValueError and act accordingly. Besides that: This is the bug tracker. Questions on how to use the modules and Python are better asked at the Forum forum.pycom.io, which can be searched and is therefore a good source of answers to questions, that you might have.