Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1107601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:57:40+00:00 2026-05-17T01:57:40+00:00

I know using below code to ignore a certain exception, but how to let

  • 0

I know using below code to ignore a certain exception, but how to let the code go back to where it got exception and keep executing? Say if the exception ‘Exception’ raises in do_something1, how to make the code ignore it and keep finishing do_something1 and process do_something2? My code just go to finally block after process pass in except block. Please advise, thanks.

try:
    do_something1
    do_something2
    do_something3
    do_something4
except Exception:
    pass
finally:
    clean_up

EDIT:
Thanks for the reply. Now I know what’s the correct way to do it. But here’s another question, can I just ignore a specific exception (say if I know the error number). Is below code possible?

try:
    do_something1
except Exception.strerror == 10001:
    pass

try:
    do_something2
except Exception.strerror == 10002:
    pass
finally:
    clean_up

do_something3
do_something4
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:57:41+00:00Added an answer on May 17, 2026 at 1:57 am

    update. The way to ignore specific exceptions is to catch the type of exception that you want, test it to see if you want to ignore it and re-raise it if you dont.

    try:
        do_something1
    except TheExceptionTypeThatICanHandleError, e:
        if e.strerror != 10001:
            raise
    finally:
         clean_up
    

    Note also, that each try statement needs its own finally clause if you want it to have one. It wont ‘attach itself’ to the previous try statement. A raise statement with nothing else is the correct way to re-raise the last exception. Don’t let anybody tell you otherwise.


    What you want are continuations which python doesn’t natively provide. Beyond that, the answer to your question depends on exactly what you want to do. If you want do_something1 to continue regardless of exceptions, then it would have to catch the exceptions and ignore them itself.

    if you just want do_something2 to happen regardless of if do_something1 completes, you need a separate try statement for each one.

    try:
       do_something1()
    except:
       pass
    
    try:
       do_something2()
    except:
       pass
    

    etc. If you can provide a more detailed example of what it is that you want to do, then there is a good chance that myself or someone smarter than myself can either help you or (more likely) talk you out of it and suggest a more reasonable alternative.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented exception handling using below code.[Edited Start] I do not know why
I'm using below code to file copy operataion in windows seven,but it doesn't work
I am using the below code. I just dont know why it is not
I am using the below code to disable the keyboard combination hooks. I got
I am using the below code to iterate through multiple nodes of XML but
How to generate unique id's in Javascript? I know using uuid in java, but
I know that using Dim currUser As String = Request.ServerVariables(LOGON_USER) returns the Domain\Username, but
I am using below code to Add SummaryLinkWebPart to a Page and also adding
I have a UITableView which loads data from XML using the below code. It
I'm Trying to find Timezone for a Country by Using Below Code. // FIND

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.