Java Exception throw object and get object from catch -
i want pass object while getting exception , getting catch. have userdataexception
extend exception
throw new userdataexception("media uploaded failed",mediado, dupkexp);
mediado
object.
if possible mediado
object catch
statement
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 message , 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 message , throwable object * * @param schdulerdata * @param message * @param throwable */ public userdataexception(string message, mediado mediado, final throwable throwable) { super(dkerror + message, throwable); }
}
please if possible..
you have store reference object in exception class , use getter :
private mediado mediado; public userdataexception(string message, mediado mediado, final throwable throwable) { super(dkerror + message, throwable); this.mediado = mediado; } public mediado getmediado() { return mediado; }
then in catch block :
catch (userdataexception uexp) { mediado mediado = uexp.getmediado(); ... }
Comments
Post a Comment