comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: Catching a DEVICE_ERROR?
Date: Wed, 11 Jun 2003 08:49:45 -0500
Date: 2003-06-11T08:49:45-05:00	[thread overview]
Message-ID: <veecrskf24cfae@corp.supernews.com> (raw)
In-Reply-To: 5771e505.0306110531.2df2d93a@posting.google.com


"Tony Danezis" <antonis01@in.gr> wrote in message
news:5771e505.0306110531.2df2d93a@posting.google.com...
> Hello..
>
> I am looking for assistance on how to catch a DEVICE_ERROR when
> printing to LPT1. My Code seems to be correct and I print fine when
> the printer (HP laserjet 1200)is ON, but the exception is not raised
> when the printer is unplugged or not powered on.
> (Using win 2000 and The GNAT Integrated Environment version 3.14a1)
>
> thanks for any insight and assistance
> Snippet of code follows:

Why not make your exception handler like this:

exception
    when e: others =>
        Ada.Text_IO.Put_Line
           (Ada.Text_IO.Standard_Error,
            Ada.Exceptions.Exception_Information (e));
end Printer_Test;

Now, no matter what the exception, information about it will
be sent to the standard error file.

>
> with ADA.IO_EXCEPTIONS; use ADA.IO_EXCEPTIONS;
> with TERMINAL;          use TERMINAL;
> with Ada.Text_IO;       use Ada.Text_IO;
>
> procedure Printer_Test is
>   use Text;
>   PrFile : TEXT.File_Type;
>
> begin
>   Create (File => PrFile, Mode => Out_File, Name => "LPT1:");
>   Put_Line (File => PrFile, Item => "Here is a line for the printer");
>   New_Page (File => PrFile);
>   Close (File => PrFile);
>
>   Put_Line("DONE CODE");
>
>    exception
>       when Text.Status_Error =>
>         Text.Put_Line("Status_Error");
>
>       when Text.Mode_Error   =>
>         Text.Put_Line("Mode_Error");
>
>       when Text.Device_Error =>
>         Text.Put_Line("Device_Error");
>
>       when others =>
>         Text.Put_Line("Unknown_Error");
>
> end Printer_Test;
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>





  reply	other threads:[~2003-06-11 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-11 13:31 Catching a DEVICE_ERROR? Tony Danezis
2003-06-11 13:49 ` David C. Hoos [this message]
2003-06-12 10:47   ` Tony Danezis
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox