Catch exception with message?

Ian Kelly ian.g.kelly at gmail.com
Fri Jun 3 20:25:18 EDT 2016


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



More information about the Python-list mailing list