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方法.. –