java - Remove exception string from complete error message -
i have show error user error string has exception class name
com.company.module.customexception: unable find user
i want substring full string , want "unable find user" there regex can me. note exception class generated on run time.
thanks,
i suggest not string operations substring or regex deal exception messages, rather ideal way handle use yourexceptionobj.getmessage()
, need set exception message in customexception
class constructor calling super(message)
.
public class customexception extends exception { public customexception(string message) { super(message); } //add other code here }
now, if call yourexceptionobj.getmessage()
, message thrown during exception.
Comments
Post a Comment