git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Catch exception with message?


try:
    something
except Exception as e:
    if e.args[0] == message_of_interest:
        handle_it
    else:
        raise

On Fri, Jun 3, 2016 at 5:14 PM, Piyush Verma <114piyush at gmail.com> wrote:
> Generally we catch exception using
> except Exception as e:
>
> But sometimes, we see same type of exception is present with different
> message.Is there a way to capture same exception with message
> filtering? Please help me to do this.
>
> Regards,
> ~Piyush
> --
> https://mail.python.org/mailman/listinfo/python-list