Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » Try / catch 
	
		
		
			   Try / catch [message #12418] | 
			Mon, 29 October 2007 10:56   | 
		 
		
			
				
				
				
					
						  
						pippo
						 Messages: 17 Registered: October 2007  Location: Italy
						
					 | 
					Promising Member  | 
					 | 
		 
		 
	 | 
 
	
		Hello guru! 
  I have a question: try/catch handles only throw command or all exceptions? 
 
I write this code: 
int main()
{
   printf("start\n");
   try
   {
      int a = 0;
      int b = 0 / a;
   }
   catch(...)
   {
      printf("error\n");
   }
   printf("end\n");
   return(0);
}
 
 
Then, my program crash at line with "b=0/a". 
With Ubuntu and U++ (debug mode and release mode) 
and also with Windows Xp and Microsoft Visual Studio!!! 
(Visual studio show a pop-up, to inform about exception). 
 
WHY??? 
 
But, if I insert a "throw", then it jump correctly to catch(...). 
I must verify all possible errors and insert my "throw"??? I don't belive!!! 
Maybe I must active some flag? 
		
		
  10aa3a8774daeb994a88cc07572e2b6c
		
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |  
	
		
		
			| Re: Try / catch [message #12432 is a reply to message #12427] | 
			Tue, 30 October 2007 12:26   | 
		 
		
			
				
				
				
					
						  
						mdelfede
						 Messages: 1310 Registered: September 2007 
						
					 | 
					Ultimate Contributor  | 
					 | 
		 
		 
	 | 
 
	
		| luzr wrote on Tue, 30 October 2007 09:39 |  
  
Well, when exception occurs, it stops at instruction that caused exception. F10 tries to perform it again - this is standard behaviour with all debugers I know... 
 
If you want to skip it (which most likely will break the program logic anyway), you need to change the IP. 
 
  |  
  
 
In theory (IMHO) the debugger should step to catch block... I don't know very well GDB, but the Borland debugger had options to catch exceptions OR to leave the handling to the debugged program. 
 
Ciao 
 
Max 
 
		
		
		
 |  
	| 
		
	 | 
 
 
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 08:36:09 CET 2025 
 Total time taken to generate the page: 0.04416 seconds 
 |