Thread: unhandled execption

  1. #1
    Registered User
    Join Date
    Feb 2006

    unhandled execption

    Hi, i got this program to book seats for a cinema show.if trying to book seats already booked,a exception is thrown.code is as follows.
    			cout<<"\n &"<<invalidSeats[0];
    			cout<<"\n &"<<invalidSeats[1];
    			cout<<"\n &"<<invalidSeats[2];
               throw SeatsNotFreeException(invalidSeatList,invalidSeats.size());// error line
    	catch(SeatsNotFreeException ex){
           	//try booking alternative seats
    	//	if(ex.bookAlternativeSeats(showSeatList)==true){
        //        //replace invalid seat numbers with new seat numbers.
    	//		adjustSeatList(seatList,numOfSeats,invalidSeats,ex.getNewValidSeats());
        //        isSeatsBooked=true;
    	//	}

    when i run it,it gives me a error: unhandled excpetion at this line "throw SeatsNotFreeException(invalidSeatList,invalidSeats .size());"

    when i run it in dev c++... it works error

    run it in microsoft visual me error !

    help !!!!
    Last edited by rahulsk1947; 06-14-2009 at 03:24 AM.

  2. #2
    The larch
    Join Date
    May 2006
    I don't think there is enough information. Have you perhaps disabled exceptions with one compiler and not with the other?

    Some notes. Catch exceptions by reference. Generally I don't believe you should throw exceptions if you are going to handle it right there (part of normal program flow).

    And tabs mixed with spaces = the indentation mess you can see in the code block.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    I don't see why that would not work as is. It is sort of odd to see an exception thrown and then caught in the same try/catch block but it is valid. It's no different than calling a function in the try portion that throws on an error condition, however, as has been stated by anon I would recommend you do not throw exceptions if you are going to handle the exception in the same place. You could do the same thing without exceptions using return values.
    Last edited by VirtualAce; 06-14-2009 at 10:27 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unhandled exceptions (throw with no try)
    By Mario F. in forum C++ Programming
    Replies: 3
    Last Post: 07-01-2006, 06:31 AM
  2. I got an unhandled exception!!
    By LegendBreath in forum Game Programming
    Replies: 7
    Last Post: 04-19-2005, 01:55 PM
  3. Unhandled Exception (Vectors)
    By wbeasl in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2004, 07:36 AM
  4. Unhandled Exceptions
    By nickname_changed in forum C# Programming
    Replies: 0
    Last Post: 03-13-2004, 08:00 PM
  5. unhandled exception error
    By trends in forum C++ Programming
    Replies: 4
    Last Post: 11-15-2002, 06:54 PM