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 wOOdy-Soft 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
Jul 12, 2001
136
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.

Part and Inventory Search

Sponsor

Back
Top