I defined a simple int error code:
#define my_error 20
Somewhere in my code, I throw this error:
throw my_error;
Now I want to try and catch this exception:
try
{
...
...
}
catch (my_error)
{
cout << "Error: my error";
}
Unfortunately, the compiler does not approve of this:
- Syntax error: constant
- catch handlers must specify one type
- 'try' block starting at line '34' has no catch handlers
Is there any way to do this?
Thanks.
source
share