2011-08-10 38 views
0

我有一个简短的问题。在我的Grails项目中,我正在进行一些Web服务调用。如果没有足够的字符进行搜索,其中一个调用(对于搜索功能而言)往往会超时。我无法增加所需字符的数量,因此我试图捕捉异常并显示一个错误页面,要求用户添加更详细的参数。Apache错误与投掷类不兼容

的方法是这样的:

import org.apache.http.client.HttpResponseException 

class RestSearchService implements SearchService { 
    List<Person> getPersonSearch(String fName, String lName) throws HttpResponseException { 
     ... 
     // Make the call 
     ... 
    } 
} 

我,然后赶上抛出的异常控制器重定向到错误页面。我测试过了,这段代码看起来很好。问题是,上面的方法有下划线(我使用的是SpringSource工具套件的IDE),并说

Exception HttpResponseException is not compatible with 
throws clause in SearchService.getPersonSearch(String, String) 

有谁知道可能会导致什么呢?另外,这是否意味着这会导致应用程序崩溃的实际问题或情况?就像我所说的,从我可以告诉throw/redirect像冠军一样工作,但是这个错误让我担心应用程序转到生产。

由于提前,

-Mike

回答

1

我要说的是你的接口SearchService是不对的!接口中的方法'getPersonSearch'的签名是什么?

它是这样的:

List<Person> getPersonSearch(String fName, String lName); 

或像这样:

List<Person> getPersonSearch(String fName, String lName) throws HttpResponseException; 

第二个是正确的,如果你有第一个,这就是应该的问题!

+0

感谢您指出复制/粘贴错误 - 我已修复它!另外,你是绝对正确的,我忘了把错误丢到我的界面中。谢谢您的帮助! –