我不明白为什么我在这个Ada异常中收到错误。我在以下示例中收到此错误:
"Send_Command_Failed" is not visible (more references follow) 1085:12
看来我需要在sample_client.ads中声明异常,然后代码编译,但我发现这种方法是非模块化和反直觉的。所以问题是我怎么能这样做" 对"并从command_interface模块导出。
示例客户端,如...
-- sample_client.adb --
:
with command_interface;
:
package body sample_client is
procedure example is
begin
: ... stuff
exception
when Send_Command_Failed =>
Trace_Error( "Send Exception: Send_Command_Failed at example");
raise;
end example;
end sample_client;
这里的库接口:
-- command_interface.ads --
package command_interface
:
exception Send_Command_Failed;
:
end command_interface;
Body中的一些代码可以抛出Send_Command_Failed异常......
-- command_interface.adb --
package body command_interface
: ... code raises: Send_Command_Failed
:
end Command_Interface; -- specification
package body command_interface
: ... code raises: Send_Command_Failed
:
end Command_Interface; -- specification
答案 0 :(得分:2)
您是否试图告诉编译器在哪里找到异常声明?
exception
when command_interface.Send_Command_Failed =>