FinalStateMachine/src/main/java/me/bvn13/fsm/exceptions/FsmException.java

24 lines
644 B
Java
Raw Normal View History

2022-07-07 02:15:12 +03:00
package me.bvn13.fsm.exceptions;
2017-12-28 15:30:26 +03:00
import java.io.PrintWriter;
import java.io.StringWriter;
/**
2022-07-07 02:15:12 +03:00
* Parent FSM exception class
2017-12-28 15:30:26 +03:00
*/
2022-07-07 02:15:12 +03:00
public class FsmException extends RuntimeException {
2017-12-28 15:30:26 +03:00
protected String message;
2022-07-07 02:15:12 +03:00
public FsmException(String message) {
2017-12-28 15:30:26 +03:00
this.message = message;
}
protected String getStackTraceString() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
this.printStackTrace(pw);
return sw.toString();
}
public void printStackTrace() {
System.out.println(String.format("FSMException: %s / %s", message, getStackTraceString()));
}
}