1
0
forked from 0ad/0ad

Error code to exception conversion, via ThrowError(code)

This was SVN commit r1039.
This commit is contained in:
Ykkrosh 2004-08-24 11:09:11 +00:00
parent 9fa5e3b57a
commit a684d27654

View File

@ -22,6 +22,11 @@ for (@files) {
}
}
# Add "PSERROR_Error_InvalidError", so that an error to throw when being
# told to throw an error that doesn't exist exists.
$topgroups{Error} = 1;
$types{'Error~InvalidError'} = 1;
open my $out, '>', 'ps/Errors.cpp' or die "Error opening ps/Errors.cpp ($!)";
print $out <<'.';
@ -162,6 +167,22 @@ print $out <<".";
\t}
\treturn L"Unrecognised error";
}
void ThrowError(PSRETURN code)
{
\tswitch (code)
\t{
.
for (sort keys %types) {
(my $name = $_) =~ s/~/_/;
print $out qq{\tcase 0x}.unpack('H*',$types{$_}).qq{: throw PSERROR_$name();\n};
}
print $out <<".";
\t}
\tthrow PSERROR_Error_InvalidError(); // Hmm...
}
.