Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
handle the error
#2
I would start by understanding what is going on when the Value Error exception is raised. What is returned by receive()? Maybe start with something like this:
def get_dcv(self):
    self.connector.send('DCV?')
    try:
        value = self.connector.receive()
        return float(value)
    except ValueError:
        print(f"Expecting a float but got '{value}'")
    return 0
Now you can see what you get when this error occurs. Do the non-float return values contain important information?
Reply


Messages In This Thread
handle the error - by Irv1n - Nov-29-2021, 06:20 PM
RE: handle the error - by deanhystad - Nov-29-2021, 06:34 PM
RE: handle the error - by Irv1n - Nov-29-2021, 07:03 PM
RE: handle the error - by deanhystad - Nov-29-2021, 07:53 PM
RE: handle the error - by Irv1n - Nov-29-2021, 07:55 PM
RE: handle the error - by deanhystad - Nov-29-2021, 08:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 2,881 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  Need suggestion how to handle this error farrukh 1 2,381 Dec-21-2019, 03:21 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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