John Dammeyer wrote:
> I'm printing out using a pdf library that is throwing an exception.
>
> Type
> PDFException = Exception;
That makes PDFException an alias for Exception. It will be better if you
define the one as a descendant of the other.
type
EPDFException = class(Exception);
Look at the declarations in SysUtils for more examples.
> Then in the code...
>
> raise PDFException.Create('Error in BeginDoc!');
The first thing I'd wonder, when I saw an error message like that, is
what kind of error? Can your code be any more specific about what went
wrong?
> Except the text is 'Invalid Filename' which I can't find in the source.
So, you're raising an exception, but the text isn't what you told it to be?
> My application is doing a
>
> try
> PDFPrinter.BeginDoc;
> except
> MessageDlg(
> 'Can''t print "'+SummaryFileName+
> '" to Memory Dongle -- Make sure there is file space and try
> again.',
> mtConfirmation,
> [mbOK],
> 0);
You're showing a dialog box in response to an exception without any
knowledge of what the exception is. Never do that. Always catch a
specific type of exception, and let the ones you aren't prepared to
handle propagate up the stack to something that is prepared to handle them.
except
on E: EPDFException do begin
// ...
end;
end;
That will catch only PDF exceptions.
All descendants of Exception have a Message parameter, which holds the
string passed to the exception when it was constructed.
--
Rob
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi