comp.lang.ada
 help / color / mirror / Atom feed
* Catching a DEVICE_ERROR?
@ 2003-06-11 13:31 Tony Danezis
  2003-06-11 13:49 ` David C. Hoos
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Danezis @ 2003-06-11 13:31 UTC (permalink / raw)


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:

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;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Catching a DEVICE_ERROR?
  2003-06-11 13:31 Catching a DEVICE_ERROR? Tony Danezis
@ 2003-06-11 13:49 ` David C. Hoos
  2003-06-12 10:47   ` Tony Danezis
  0 siblings, 1 reply; 3+ messages in thread
From: David C. Hoos @ 2003-06-11 13:49 UTC (permalink / raw)



"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
>





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Catching a DEVICE_ERROR?
  2003-06-11 13:49 ` David C. Hoos
@ 2003-06-12 10:47   ` Tony Danezis
  0 siblings, 0 replies; 3+ messages in thread
From: Tony Danezis @ 2003-06-12 10:47 UTC (permalink / raw)


"David C. Hoos" <david.c.hoos.sr@ada95.com> wrote in message news:<veecrskf24cfae@corp.supernews.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.
> 

Thanks David for your suggestion...Your exception handler is a lot
more elegant, however the error is NEVER raised. Its seems when
printing to LPT1: and the printer is not present or powered on, no
exception is caught and the program hangs.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-06-12 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-11 13:31 Catching a DEVICE_ERROR? Tony Danezis
2003-06-11 13:49 ` David C. Hoos
2003-06-12 10:47   ` Tony Danezis

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