Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exception handle

Status
Not open for further replies.

vcllvc

Programmer
Joined
Jul 12, 2001
Messages
136
Location
US
Hello, can someone help me out this problem.
Let say I have the following try block:

try{
stringHandleFunction()
}catch(exceptionHandle& e)
{}

void stringHandleFunction(){
// here doing some string business,
// but somehow it will crash because of a null string
//
// how can I do a throw here, so the try block can catch it.
// Thanks in advance
}
 
#include<iostream>
void stringHandleFunction(){
// here doing some string business,
char* x=do_some_string_business();
// but somehow it will crash because of a null string
if(!x)
{
throw &quot;crash because of a null string&quot;
}
//
// how can I do a throw here, so the try block can catch it.
// Thanks in advance
//not at all
}
int main()
{
try{
stringHandleFunction()
}catch(exceptionHandle& e)
{
do_something_else(e);
}catch(char* xxx)
{
cout<<xxx<<endl;
}catch(...)
{
cout<<&quot;unknown error&quot;<<endl;
}
return 0;
} John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Similar threads

Replies
1
Views
1K
Replies
2
Views
322
  • Locked
  • Question Question
Replies
5
Views
506
Replies
2
Views
366

Part and Inventory Search

Sponsor

Back
Top