Error Handling - Intermediate Python Programming p.23

preview_player
Показать описание
In this tutorial, we cover a method for handling errors in larger programs, since, normally, if you just return the str(e), the error is relatively minimalistic, and you may actually want to grab more information. For this reason, we're going to use the sys module to get more information from the exception.

Рекомендации по теме
Комментарии
Автор

Thank you so much for this. Really straight forward explanation on how to collect the error information.
Will definitely update my current projects with this.

idle_user
Автор

You really should talk about how catching a general Exception like 'Exception' is generally a really bad idea. You want to catch the narrowest exception as you can to be able to handle it appropriately and have as little code as you can inside the try block again to be able to handle the exception and trace it easier. Also another cool thing just to talk about would be using else: in addition to the try: except: block.

koolaidman
Автор

Awesome video, very useful and thank you a lot. Love all your videos, very well explained. One of the few tutorials I can actually follow easily :)

mustardthunder
Автор

Have you tried
logging.exception('<insert error message here>')
This will take the current exception and log it in a graceful manner.

AdamBecker
Автор

I know you formatted the exception but if you wanted the whole thing you could just put :
logger.error('An error occured', exc_info=1)

jasonlloyd
Автор

If someone has a great idea for an app but does not know how to code but is willing to learn how to code to make it happen, would u find it better for that person to learn and make there own app or get some other coding company to do it for them? Even tho the person is scared of there ideas being stolen? Pls include on your QnA video

laissez-faire
Автор

Are you thinking in doing a testing series?

MentiSnap
Автор

Importing sys seems unnecessary, the same tuple returned by sys.exc_info() can be created like this: (e.__class__, e, e.__traceback__).

Majskolvenz