- Subject: Re: [slang-users] EXIT_BLOCK not executed on Error
 
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
 
- Date: Sat, 6 Sep 2008 20:20:58 -0400
 
On Sat, 6 Sep 2008 20:17:38 +0000 (UTC), Jörg Sommer <joerg@xxxxxxxxxxxx>
wrote:
> I expect this code prints ‘foo’ and the error message, but it prints only
> the error message.
>
> % cat /tmp/test.sl
> define test()
>{
> #ifexists push_spot
>     push_spot();
>     EXIT_BLOCK
>    {
>         pop_spot();
>    }
>     () = eob();
> #else
>     EXIT_BLOCK
>    {
>         message("foo");
>    }
> #endif
>     throw NotImplementedError;
>}
> test();
> % slsh /tmp/test.sl
> Not Implemented
> /tmp/test.sl:16:test:Not Implemented
>
> I expect
> % slsh /tmp/test.sl
> foo
> Not Implemented
> /tmp/test.sl:16:test:Not Implemented
>
> Is this a bug?
No.  The EXIT_BLOCK will not get executed in the presence of an error.
Consider using a `finally' block, e.g., 
define slsh_main ()
{
   try
     {
	throw NotImplementedError;
     }
   finally
     {
	message ("foo");
     }
}
Thanks,
--John
  [2008 date index]
  [2008 thread index]
  
  [Thread Prev] [Thread Next]
      
  [Date Prev] [Date Next]