1
我想在获取异常并从catch中获取时传递对象。 我有UserDataException
自Exception延伸Java异常抛出对象并从catch中获取对象
throw new UserDataException("Media uploaded failed",mediaDO, dupkExp);
mediaDO
是对象。
如果可能的话,从catch
说法得到这个mediaDo
对象
catch (UserDataException uExp) {
}
UserdataException
CALSS:
public class UserDataException extends Exception {
private static final String ERROR = "Database Transaction Error: ";
private static final String DKERROR = "Duplicate Key Error";
/**
*
*/
private static final long serialVersionUID = 6209976874559850953L;
/**
*
*/
public UserDataException(String message, Throwable throwable) {
super(message, throwable);
}
public UserDataException(String message) {
super(message);
}
/**
* <code>UserDataException</code> thrown with message and throwable object
*
* @param schdulerData
* @param message
* @param throwable
*/
public UserDataException(String message, SchedulerData schdulerData, final Throwable throwable) {
super(ERROR + message, throwable);
}
/**
* <code>UserDataException</code> thrown with message and throwable object
*
* @param schdulerData
* @param message
* @param throwable
*/
public UserDataException(String message, MediaDO mediaDO, final Throwable throwable) {
super(DKERROR + message, throwable);
}
}
如果可能的话,请帮助..
ü可以提供异常类中的getter方法.. –