Python Forum
looking for a custom exception
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looking for a custom exception
#1
Hey everyone,

I am working on a python script that uses a thermometer. I want to put a line of code in that test to make sure the thermometer is hooked up, so I using "try except".

I found a library that seems to do a good job, but the error code that comes back when the thermometer is missing is:

w1thermsensor.errors.NoSensorFoundError: 
Could not find sensor of type DS18B20 with id 0300a27989942
Please check cabling and check your /boot/config.txt for
dtoverlay=w1-gpio
is there a way I can tell Try ... Except to look for that error in particular?

I tried:

try:
   verify code:
except w1thermsensor.errors.NoSensorFoundError
   return results
Any ideas?

Thanks
Reply


Messages In This Thread
looking for a custom exception - by JarredAwesome - Sep-21-2020, 02:26 AM
RE: looking for a custom exception - by bowlofred - Sep-21-2020, 04:00 AM
RE: looking for a custom exception - by buran - Sep-21-2020, 05:25 AM
RE: looking for a custom exception - by buran - Sep-21-2020, 05:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  custom exception dcr 1 278 Feb-17-2024, 08:19 PM
Last Post: Gribouillis
  problem using custom exception handling in python srm 3 3,073 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  During handling of the above exception, another exception occurred Skaperen 7 26,931 Dec-21-2018, 10:58 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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