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 6659279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:00:53+00:00 2026-05-26T02:00:53+00:00

Is there a way allow execution of a bad block of code after an

  • 0

Is there a way allow execution of a bad block of code after an exception of thrown?

Presently, my code has an while loop that runs continuously. The code inside this while loop sometimes throws a vector out of range error. I have been unable to track down the cause of this particular exception, but ultimately, it doesn’t matter much because the code inside the while loop does the same thing over and over again and the next iteration does not depend on the previous iteration in any way.

This, after the code within the while loop crashes, I would like it to start again from the top of the while statement.

Is there a way to accomplish this in C++? try/catch doesn’t seem to work in this situation.

Additional Info:
I would love to just take the code within the while loop, make it into its own executable, and put the while loop into a bash script, but there’s some data each iteration requires that remains static and it takes too much time to re-load that data each time so I am forced to do my infinite while loop within C++

  • 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-26T02:00:53+00:00Added an answer on May 26, 2026 at 2:00 am

    You just need to catch the exception inside the while loop:

    while(true) 
    {
        try 
        {
              // your code
        }
        catch (Exception e) { /* Please, at least do some logging or other error handling here*/ }
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to allow a user, after he has created a vector
I'm hoping there's a way in a config file or something that will allow
Is there some standard way or has anyone written something that allows you to
Is there a way to allow an HTML file to open an application on
Is there a way to allow the user to add additional items to one
Using SQL Server 2008, is there a way to allow inserts to a table
Is there a way (hacky will do) to allow a user to go back
Using htmlentities() is there a way I can set to allow only <b> and
Is there something in jquery that would allow me to differentiate between behavior on
While I realize there is a similar question ( How to serialize an Exception

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.