Skip to content

Commit 8fa6deb

Browse files
committed
Improve exception message
1 parent 97f851a commit 8fa6deb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/AbstractComponentView.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public T getViewModel() {
4747
public final void initialize() {
4848
var descriptor = this.viewModel.getDescriptor();
4949
try {
50-
if (descriptor.stateWrapper().get() != ComponentState.CREATING) {
51-
throw new IllegalStateException("Unexpected state of the component");
50+
var currentState = descriptor.stateWrapper().get();
51+
if (currentState != ComponentState.CREATING) {
52+
throw new IllegalStateException("Unexpected state of the component - " + currentState.name());
5253
}
5354
preInitialize(viewModel);
5455
descriptor.stateWrapper().set(ComponentState.INITIALIZING);
@@ -75,8 +76,9 @@ public final void initialize() {
7576
public final void deinitialize() {
7677
var descriptor = this.viewModel.getDescriptor();
7778
try {
78-
if (descriptor.stateWrapper().get() != ComponentState.INITIALIZED) {
79-
throw new IllegalStateException("Unexpected state of the component");
79+
var currentState = descriptor.stateWrapper().get();
80+
if (currentState != ComponentState.INITIALIZED) {
81+
throw new IllegalStateException("Unexpected state of the component - " + currentState.name());
8082
}
8183
preDeinitialize(viewModel);
8284
descriptor.stateWrapper().set(ComponentState.DEINITIALIZING);

0 commit comments

Comments
 (0)