comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Ada95 location information
Date: 1999/06/15
Date: 1999-06-15T00:00:00+00:00	[thread overview]
Message-ID: <99-06-067@comp.compilers> (raw)
In-Reply-To: 99-06-064@comp.compilers

dommo1234@my-deja.com writes:

> I'm writing a program in Ada95 and require that when exceptions are
> thrown, the location in the source code is included in the message, not
> just in the call stack display. I realise there's no pre-processor, but
> C and C++ compilers have special tags, eg. "__LINE__", and I wonder
> whether Ada compilers have anything silimar. Does anyone know of any
> way to obtain this information from the compiler at compile time?

I just use Ada.Exceptions.Raise_Exception, and include the full name
of the subprogram in the message:

package body Foo is
   procedure Bar is
   begin
      if Error then
         Ada.Exceptions.Raise_Exception
            (Something_Bad'identity,
             "Foo.Bar : file not found");
      end if;
  end Bar;
end Foo;

This is easy to do. Possibly not quite as easy as a preprocessor
macro, but typing the subprogram name also makes you think about what
else should be in the error message.

One problem with this approach is that Ada.Exceptions is _not_ labeled
with pragma Preelaborate, so you end up using pragma Elaborate_Body
instead, which is not as nice. I hope this will be fixed in an AI
soon.

-- Stephe




      reply	other threads:[~1999-06-15  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-14  0:00 Ada95 location information dommo1234
1999-06-15  0:00 ` Stephen Leake [this message]
replies disabled

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