"Sergey Koshcheyev" a �crit dans le message de news:bat3ee$2ec$1@ns.felk.cvut.cz... [..] > procedure Read_Something (...) is > use Ada.Text_IO; > use Ada.Strings.Unbounded; > use Ada.Strings.Unbounded.Text_IO; > -- GNAT-specific package, I believe > > File : File_Type; > S1, S2 : Unbounded_String; > > begin > Open (File, Name => "test.txt", Mode => In_File); > Get_Line (File, S1); > Get_Line (File, S2); > Close (File); > > exception > when others => > if Is_Open (File) then > begin > Close (File); > exception > -- Close can raise exceptions too! > when others => null; > end; > end if; > end Read_Something; Doing so will make the exception disappear. You exception handler should rather read: exception when others => if Is_Open (File) then begin Close (File); exception -- Close can raise exceptions too! when others => null; end; end if; raise; -- Reraise the original exception, even if you had another exception at close end Read_Something; > However, this looks ugly to me, since I have to close the file in two > places, and also guard for exceptions while handling exceptions. Is there a > better solution or is this sort of thing OK in the Ada way? > > Sergey. > >