如何处理xapian php异常
帮助使用 xapian php 包装器。
我有几个针对不同类别的错误的自定义异常处理程序(我正在考虑将它们进一步分离)。
Xapian 通过抛出标准 Exception 对象来处理错误。 不过,我想为这些使用自定义异常处理程序。 如何针对已引发的标准异常使用自定义异常? 或者任何其他想法,也许如何让 Xapian 抛出其他异常类型?
Help with using the xapian php wrapper.
I have a couple of custom exception handlers for different categories of errors (I'm thinking of seperating them out more).
Xapian handles errors by throwing standard Exception objects.
I would like to use a custom exception handler for these though. How do I go about using a custom exception for a standard Exception that has already been thrown? Or any other ideas, perhaps how to get Xapian to throw some other exception type?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
笨拙的方式:将每个 xapian API 调用包装在 try..catch 块中,并在 catch 子句中抛出更具体的自定义异常。
或 hackish 方式:修改 xapian php 扩展的源代码(我假设是用 C 编写的?)以抛出自定义异常(您还必须在扩展源代码中定义)
the kludgy way: wrap every xapian API call in try..catch blocks, and throw more specific custom exceptions in the catch clause.
or the hackish way: modify the source of the xapian php extension (which i assume is written in C?) to throw custom exceptions (that you would also have to define in the extension source)
从 Xapian 捕获一般异常,弄清楚它们是什么,然后抛出更具体的期望。
或者...如果您希望 Xapian 的行为与当前不同,那么,它是一个开源项目。 你知道该做什么。 :)
Catch the generic exceptions from Xapian, figure out what they are, then throw more specific expections.
Or...if you'd like Xapian to behave differently than it currently does, well, it is an open source project. You know what to do. :)