pb9自定义事件(函数)中,有个THROWS,如何填写

swordlhh 2013-04-29 09:35:29
pb9自定义事件(函数)中,有个THROWS,里面不知如何填写??

这个THROWS在什么时候起作用??
THROWS出来的异常,是谁去捕获(接管)的??

恳请高手指点!!万分感激
...全文
238 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
swordlhh 2013-04-30
  • 打赏
  • 举报
回复
多谢版主释疑 我理解为与通过代码定义函数时,后面加上throws myexcption一样。
WorldMobile 2013-04-30
  • 打赏
  • 举报
回复
这是pb帮助里的关于throws的说明,你研究一下吧
WorldMobile 2013-04-30
  • 打赏
  • 举报
回复
帮你找了一下帮助 Defining a THROWS clause If you are using user-defined exceptions, you must define what exceptions might be thrown from a user-defined function or event. You use the Throws box to do this. When you need to add a THROWS clause Any developers who call the function or event need to know what exceptions can be thrown from it so that their code can handle the exceptions. If a function contains a THROW statement that is not surrounded by a try-catch block that can deal with that type of exception, then the function must be declared to throw that type of an exception or some ancestor of that exception type. There are two exception types that inherit from the Throwable object: Exception and RuntimeError. Typically, you add objects that inherit from Exception to the THROWS clause of a function. Exception objects are the parents of all checked exceptions, which are exceptions that must be dealt with when thrown and declared when throwing. You do not need to add Runtime error objects to the THROWS clause, because they can occur at any time. You can catch these errors in a try-catch block, but you are not required to. Adding a THROWS clause You can add a THROWS clause to any PowerBuilder function or to any user event that is not defined by an event ID. To do so, drag and drop it from the System Tree, or type the name of the object in the box. If you type the names of multiple user objects in the Throws box, use a comma to separate the object names. When you drag and drop multiple user objects, PowerBuilder automatically adds the comma separators. The PowerBuilder compiler checks whether a user-defined exception thrown on a function call in a script matches an exception in the THROWS clause for that function. It prompts you if there is no matching exception in the THROWS clause. You can define a user-defined exception object, and inherit from it to define more specific lower-level exceptions. If you add a high-level exception to the throws clause, you can throw any lower-level exception in the script, but you risk hiding any useful information obtainable from the lower-level exception. For more information about exception handling, see Application Techniques .

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧