exceptions

Hi everyone!
im writing a code, and im requested to use execptions.
my question- where do i put the "throw" calls? in the main> in the function? in the class?
and the same for the "try" call.
for example- part of my code:

1
2
3
4
5
 //Main
cout<<"Insert product's serial number, composed of 5 integers: ";
			cin>>serial;
cout<<endl<<"Insert product's quantity(weight at stock, at least 1).";
			cin>>quantity;


must i write try&catch for each of the cases? or there is option to do one try for all cases? in addition, i want that if wrong input had recieved, the code would have scanned another values, untill it is correct. how do i do this?

thanks!
Last edited on
You don't need exceptions/try/catch with input handling. If you want to repeatedly ask the user to enter valid input, read http://www.LB-Stuff.com/user-input

You only throw exceptions where you don't know how to recover from an error.
You only catch exceptions where you do     know how to recover from an error.
Last edited on
thank you. so if i want to use the throw command in order to start getting inputs again,
its possible ?
No. It's a bad idea because you should never throw an exception if you can handle the problem.
thanks :)
Topic archived. No new replies allowed.