4 ms·
> 2. error checking What I want? I want to a) have an option where an unchecked return error causes the program to log and exit. error SomeFn(int blah, in
by Gibbon1 10y ago
> 2. error checking
What I want? I want to
a) have an option where an unchecked return error causes the program to log and exit.
error SomeFn(int blah, int haw)
{
if(blah < 0 || haw < 0)
error(1);
return(bah*haw);
}
// program will die here
SomeFn(-20, 23);
// program will not die here
if(SomeFn(-20, 23) != 0)
{
// something
}
b) be able to pass a label to a function to handle errors.
Example
int SomeFn(int blah, int haw, error oops)
{
if(blah < 0 || haw < 0)
oops(1);
return(bah*haw);
}
int res = SomeFn(-20, 23, crap);
printf("res =%i\n", res);
// SomeFn returns here
crap:
print("parameters can't be negative");