atsuyaw / RPIoTlogger

Raspberry Pi PicoW to get sensor output and post API for InfluxDB
MIT License
0 stars 0 forks source link

Post error status in exception #3

Open atsuyaw opened 3 weeks ago

atsuyaw commented 3 weeks ago

Once an exceptional error is returned, report it by API and reboot the device. This make be able to explicitly fire alert with reasons.

atsuyaw commented 3 weeks ago

raise may be available for this https://uxmilk.jp/39845

atsuyaw commented 6 days ago
import utime

def timer():
    if utime.ticks_diff(utime.ticks_ms(), start) > 2000:
        raise ValueError
    time = utime.ticks_diff(utime.ticks_ms(), start)
    print(time)
    utime.sleep(1)

start = utime.ticks_ms()

while True:
    try:
        timer()
    except ValueError:
        start =+ 1
        print(start)
    except RuntimeError:
        print("Run time err")
        raise
    except Exception:
        # print(f"Unexpected {err}, {type(err)}")
        print("Unexpected")
        raise