java - How can I get the name of the class that throws a custom made Exception -


i'm preparing project college need write custom made exception thrown couple of classes in same package when not initialized properly. problem must let user know of classes wasn't initialized (and throwed exception)... thinking this:

class initializationexception extends exception {  private static final string default_msg =             "this " + classname-throwingme + " had not been initialized properly!";      protected string msg;  initializationexception() {     this.msg = default_msg; }      initializationexception(string msg) {     this.msg = msg; } } 

(btw, can achieved via reflection?)

look @ throwable.getstacktrace(). each stacktraceelement has getclassname(). can @ element [0] determine origination of exception.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -