抛出错误调用方法! [英] Throw error to calling method!

查看:310
本文介绍了抛出错误调用方法!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个线程类和在运行方法我正在调用一个web服务,这个调用是在一个try catch

  try {
//使Web服务调用
}
catch(Exception e){
throw e;
}

Eclipse不喜欢这个!


$

解决方案

基本上,我想将这个错误抛给调用方法。抛出一个检查异常,异常必须用try / catch处理,或者声明它在方法签名中抛出。请参阅例外教程;特别是有关三种例外情况的部分。


I have a thread class and in the run method I am making a call to a web service, this call is in a try catch

try {
    // Make webs service call
}
catch (Exception e) {
    throw e;
}

Eclipse doesn't like this!

Basically I want to throw this error to the calling method and deal with it there?

解决方案

If you throw a checked exception, the exception must be handled either with try/catch or declaring it as thrown in the method signature. See the exceptions tutorial; particularly the part about The Three Kinds of Exceptions.

这篇关于抛出错误调用方法!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆