代码之家  ›  专栏  ›  技术社区  ›  Mawg says reinstate Monica

Ada-详细描述在哪里?

  •  1
  • Mawg says reinstate Monica  · 技术社区  · 7 年前

    我在看 this example ADA中的异常处理。

    我需要什么 with 对于 Verbosity_Desired ?

       with Ada.Text_IO;
       with Ada.Exceptions;
       with File_System; use File_System;
       use Ada;
       procedure Main is
       begin
           ... -- call operations in File_System
       exception
           when End_Of_File =>
               Close(Some_File);
           when Not_Found_Error : File_Not_Found =>
               Text_IO.Put_Line(Exceptions.Exception_Message(Not_Found_Error));
           when The_Error : others =>
               Text_IO.Put_Line("Unknown error:");
               if Verbosity_Desired then
                   Text_IO.Put_Line(Exceptions.Exception_Information(The_Error));
               else
                   Text_IO.Put_Line(Exceptions.Exception_Name(The_Error));
                   Text_IO.Put_Line(Exceptions.Exception_Message(The_Error));
               end if;
               raise;
       end Main;
    
    1 回复  |  直到 7 年前
        1
  •  3
  •   jdex    7 年前

    在我看来你不需要 with 什么…这可能只是表演,也许 Verbosity_Desired 是一个布尔值,你可以定义自己。

    这个来自LRM的例子是关于异常以及如何获取有关异常的信息,因此它可能只是演示通过使用 Exceptions.Exception_Information .