Steven D'Aprano wrote:
> try:
> main()
> except Exception as err:
> log(err)
> print("Sorry, an unexpected error has occurred.")
> print("Please contact support for assistance.")
> sys.exit(-1)
>
>
I like the traceback[0] module for logging last exception thrown.
See tracebac
On Tue, Apr 9, 2013 at 5:41 AM, wrote:
> try:
> response = urllib.request.urlopen(request)
> content = response.read()
> except BaseException as ue:
> if (isinstance(ue, socket.timeout) or (hasattr(ue, "reason") and
> isinstance(ue.reason, sock
On Wed, Apr 10, 2013 at 1:05 AM, Steven D'Aprano
wrote:
> One exception to this rule (no pun intended) is that sometimes you want
> to hide the details of unexpected tracebacks from your users. In that
> case, it may be acceptable to wrap your application's main function in a
> try block, catch an
On Tue, 09 Apr 2013 06:19:09 -0700, cabbar wrote:
> How do I
> handle all other exceptions, just say Exception: and handle them? I want
> to silently ignore them.
Please don't. That is normally poor practice, since it simply hides bugs
in your code.
As a general rule, you should only catch exce
cab...@gmail.com wrote:
> Ah, looks better.
>
> But, 2 questions:
>
> 1. I should also catch ConnectionResetError I am guessing.
Does it need a special reaction? If so give it its own except suite.
> 2. How do I handle all other exceptions, just say Exception: and handle
> them? I want to sile
On 4/9/2013 7:41 AM, cab...@gmail.com wrote:
Hi,
I have been using Java/Perl professionally for many years and have been trying
to learn python3 recently. As my first program, I tried writing a class for a
small project, and I am having really hard time understanding exception
handling in url
Ah, looks better.
But, 2 questions:
1. I should also catch ConnectionResetError I am guessing.
2. How do I handle all other exceptions, just say Exception: and handle them? I
want to silently ignore them.
Thanks...
On Tuesday, April 9, 2013 2:41:51 PM UTC+3, cab...@gmail.com wrote:
> Hi,
>
>
cab...@gmail.com wrote:
> Hi,
>
> I have been using Java/Perl professionally for many years and have been
> trying to learn python3 recently. As my first program, I tried writing a
> class for a small project, and I am having really hard time understanding
> exception handling in urllib and in py
Hi,
I have been using Java/Perl professionally for many years and have been trying
to learn python3 recently. As my first program, I tried writing a class for a
small project, and I am having really hard time understanding exception
handling in urllib and in python in general...
Basically, what