* error recovery
@ 2001-05-11 13:30 Noam Kloos
2001-05-11 14:02 ` Staffan Dittmer
0 siblings, 1 reply; 3+ messages in thread
From: Noam Kloos @ 2001-05-11 13:30 UTC (permalink / raw)
Hello,
I have written a small program and I don't like the exeception
handlling;
Normally when Name_Error my program creates the missing file.
But after exception has been raised the program ends.
So my way to do it was; when Name_Error; Create File, call the program
itself.
I get a possible infinite recursion warning, but wont get storage
error while the action can occur only once.
This is my way to do error recovery (something that belongs to OOPS)
http://www.noam.nl/ada95/action.zip
Is there a better way to realise error recovery in Ada?
Noam.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: error recovery
2001-05-11 13:30 error recovery Noam Kloos
@ 2001-05-11 14:02 ` Staffan Dittmer
2001-05-11 14:42 ` Ehud Lamm
0 siblings, 1 reply; 3+ messages in thread
From: Staffan Dittmer @ 2001-05-11 14:02 UTC (permalink / raw)
In article <3afbe7e2.191078067@news.nl.uu.net>,
serious@clerk.com (Noam Kloos) writes:
> But after exception has been raised the program ends.
> So my way to do it was; when Name_Error; Create File, call the program
> itself.
>
> Is there a better way to realise error recovery in Ada?
> Noam.
>
Guess you should check the ARM about the range(?) of exceptions.
The solution to your problem is adding a new block inside your main
program, or a procedure, that handles the exception locally without
interrupting the rest of your program.
In your case a block solution would be
open_file_block:
begin
Open(File_Log,Append_File,Log_File_Name);
exception
when Name_Error => Create(File_Log,In_File,Log_File_Name);
end open_file_block;
then do all the putting things....
/ Staffan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: error recovery
2001-05-11 14:02 ` Staffan Dittmer
@ 2001-05-11 14:42 ` Ehud Lamm
0 siblings, 0 replies; 3+ messages in thread
From: Ehud Lamm @ 2001-05-11 14:42 UTC (permalink / raw)
What you do is put the code that may raise an exception inside a blok, and
since you want to try again, put the block inside a loop.
This is a standard idiom, and you can see how it is used by checking the
code examples on Adapower (http://www.adapower.com/lang/safeio.html is an
example of mine that does almost nothing except catch exceptions :-) check
the "get" routine).
--
Ehud Lamm mslamm@mscc.huji.ac.il
http://purl.oclc.org/NET/ehudlamm <== Me!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-05-11 14:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-11 13:30 error recovery Noam Kloos
2001-05-11 14:02 ` Staffan Dittmer
2001-05-11 14:42 ` Ehud Lamm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox