Python Forum
Catching a crash within a library code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Catching a crash within a library code
#6
Looks correct to me. Two things to try:

Make sure that the code logic and micropython aren't doing anything odd here. This should be caught as well:
try:
    raise OSError('Test error')
    blynk = BlynkLib.Blynk(BLYNK_AUTH,
                           insecure=False,          # disable SSL/TLS
                           server='blynk.cloud',   # set server address
                           port=443,                  # set server port
                           heartbeat=30,            # set heartbeat to 30 secs
                           log=False                   # use print function for debug logging
                           )
except OSError as e:
    print('ERROR***', e)
    #machine.reset()
And:
try:
    blynk = BlynkLib.Blynk(BLYNK_AUTH,
                           insecure=False,          # disable SSL/TLS
                           server='blynk.cloud',   # set server address
                           port=443,                  # set server port
                           heartbeat=30,            # set heartbeat to 30 secs
                           log=False                   # use print function for debug logging
                           )
except:
    print('ERROR***')
    #machine.reset()
I see no reason that the OSError shouldn't be caught, but this test should catch any possible exception. Maybe try them and see if they are both caught or not.
ebolisa likes this post
Reply


Messages In This Thread
Catching a crash within a library code - by ebolisa - Nov-21-2021, 09:08 PM
RE: Catching a crash within a library code - by bowlofred - Nov-21-2021, 11:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python best library for Excel reports & review of existing code MasterOfDestr 4 1,048 Feb-14-2024, 03:39 PM
Last Post: MasterOfDestr
  How do I open the Source code of a library? JaneTan 1 2,367 Aug-18-2021, 02:12 AM
Last Post: Larz60+
  Python Crash Course ( 2nd edition) alok 1 1,984 Jul-19-2021, 05:55 PM
Last Post: snippsat
  Modbus-tk library catching modbus-tk exception zazas321 1 2,176 Nov-10-2020, 03:06 PM
Last Post: Larz60+
  Im using python crash course version 2 james_newbie 3 2,488 Sep-07-2019, 09:21 PM
Last Post: ichabod801
  Python 3 crash course james_newbie 6 4,093 Aug-25-2019, 08:23 PM
Last Post: snippsat
  Catching Errors Alienspecimen 1 2,235 May-18-2019, 11:07 PM
Last Post: Larz60+
  Pyinstaller exe won't launch after crash kainev 0 2,690 May-11-2019, 06:06 PM
Last Post: kainev
  Pexpect not catching embeded ssh response luchoArg32 0 2,375 Feb-08-2019, 08:45 AM
Last Post: luchoArg32
  catching / handle index out of range 3Pinter 3 2,781 Feb-04-2019, 01:19 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020